diff --git a/.asf.yaml b/.asf.yaml index 66dc6d7649..63fe6434db 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -37,8 +37,8 @@ github: - microservice - state-management enabled_merge_buttons: + merge: true squash: true - merge: false rebase: false protected_branches: master: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2b0aa255b..b302599843 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,48 +33,32 @@ on: jobs: build: name: Build - - runs-on: ubuntu-latest - strategy: fail-fast: false matrix: - language: - - 'java' - java: - - 8 + os: [ubuntu-latest, macOS-latest] + java: [8, 11] + runs-on: ${{ matrix.os }} steps: - name: Checkout repository uses: actions/checkout@v2 - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - languages: ${{ matrix.language }} - - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v1 with: java-version: ${{ matrix.java }} - name: Build - # skip check here, since we use Checkstyle task to check the added file - run: ./gradlew clean build jacocoTestReport checkLicense -x check + # We use -x check to skip check code style here, since this task will check all files. + # We use Checkstyle task to check the added file + run: ./gradlew clean build jar dist jacocoTestReport -x check - - name: Perform CodeQL analysis - uses: github/codeql-action/analyze@v1 - - - name: Upload coverage report to codecov.io - run: bash <(curl -s https://codecov.io/bash) || echo 'Failed to upload coverage report!' + - name: Install plugin + run: ./gradlew installPlugin checkstyle: name: Checkstyle - runs-on: ubuntu-latest steps: @@ -96,7 +80,6 @@ jobs: license-check: name: License Check - runs-on: ubuntu-latest steps: @@ -104,6 +87,9 @@ jobs: uses: actions/checkout@v2 - name: Check license header - uses: apache/skywalking-eyes@9bd5feb86b5817aa6072b008f9866a2c3bbc8587 + uses: apache/skywalking-eyes@main env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check third party dependencies + run: ./gradlew clean jar dist && ./gradlew installPlugin && ./gradlew tar && sh tools/third-party-dependencies/check-dependencies.sh && echo "Thirty party dependencies check success" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 922026cd64..edb1b1809e 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,11 @@ classes package-lock.json node_modules .DS_Store -.run \ No newline at end of file +.run + +h2/db.mv.db + +# license check tmp file +all-dependencies.txt +self-modules.txt +third-party-dependencies.txt diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16b6b6602d..8c34df7a77 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,15 +37,15 @@ Here are the workflow for contributors: 1. Fork to your own 2. Clone fork to local repository -```shell +```git git clone git@github.com:yourgithub/incubator-eventmesh.git ``` 3. Create a new branch and work on it -```shell +```git git checkout -b fix_patch_xx ``` 4. Keep your branch in sync -```shell +```git git remote add upstream git@github.com:apache/incubator-eventmesh.git git fetch upstream develop:upstream_develop git rebase upstream_develop @@ -65,18 +65,20 @@ EventMesh repository, and the related Issue will be closed. We use [GitHub Issues](https://github.com/apache/incubator-eventmesh/issues) and [Pull Requests](https://github.com/apache/incubator-eventmesh/pulls) for trackers. -If you find a typo in a document, find a bug in code, or want new features, or want to give suggestions, you +If you find a bug in code, or want new features, or want to give suggestions, you can [open an issue on GitHub](https://github.com/apache/incubator-eventmesh/issues/new) to report it. Please follow the guideline message in the issue template. -If you want to contribute, please follow the [contribution workflow](#github-workflow) and create a new pull request. If -your PR contains large changes, e.g. component refactor or new components, please write detailed documents about its +If you want to contribute, please follow the [contribution workflow](#github-workflow) and create a new pull request. Your PR title should start with [ISSUE #xx]. +If your PR contains large changes, e.g. component refactor or new components, please write detailed documents about its design and usage. -Note that a single pull request should not be too large. If heavy changes are required, it's better to separate the +If your change is about a typo or small optimize, you needn't create an Issue, just submit a PR and title with [MINOR]. + +[Note]: A single pull request should not be too large. If heavy changes are required, it's better to separate the changes to a few individual PRs. -### Code review +### PR review All code should be well reviewed by one or more committers. Some principles: @@ -88,11 +90,18 @@ All code should be well reviewed by one or more committers. Some principles: EventMesh follows [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) policy. All source files should have the Apache License header added to the file header. EventMesh uses the [apache/skywalking-eyes](https://github.com/apache/skywalking-eyes) to check -the source file header, and EventMesh uses [Gradle-License-Report](https://github.com/jk1/Gradle-License-Report) plugin to check for third-part dependencies. -When you need to add a three-part dependency, you need to register the newly added dependency in tool/license/allowed-licenses.txt, you can execute `./gradlew clean checkLicense` to judge -whether there exist dependencies have been added, and the newly added three-part libraries need to meet [ASF 3RD PARTY LICENSE POLICY](https://apache.org/legal/resolved.html). +the source file header. + +EventMesh uses [check-dependencies.sh](tools/third-party-dependencies/check-dependencies.sh) script to check for third-part dependencies. +When you need to add a three-part dependency, you need to register the newly added dependency in tool/license/known-dependencies.txt. The newly added three-part libraries need to meet [ASF 3RD PARTY LICENSE POLICY](https://apache.org/legal/resolved.html). It is highly recommended communicating with EventMesh community before you need to add a three-part library. +### PR merge + +After a PR is approved by at least one committer, it can be merged. Before the merge, the committer can make changes to the commits message, requiring the commits +message to be clear without duplication, and use Squash and Merge to make sure one PR should only contain one commits. +For large multi-person PR, use Merge to merge, and fix the commits by rebase before merging. + ## Community ### Contact us diff --git a/CONTRIBUTING.zh-CN.md b/CONTRIBUTING.zh-CN.md index 0fede22ee3..dd6bc64a3a 100644 --- a/CONTRIBUTING.zh-CN.md +++ b/CONTRIBUTING.zh-CN.md @@ -31,15 +31,15 @@ Editor -> Code Style -> Java -> Scheme -> Import Scheme -> CheckStyle Configurat 1. Fork到您个人仓库 2. 克隆到本地存储库 -```shell +```git git clone git@github.com:yourgithub/incubator-eventmesh.git ``` 3. 创建一个新分支并对其进行处理 -```shell +```git git checkout -b fix_patch_xx ``` 4. 保持分支与主库同步 -```shell +```git git remote add upstream git@github.com:apache/incubator-eventmesh.git git fetch upstream develop:upstream_develop git rebase upstream_develop @@ -56,19 +56,20 @@ git rebase upstream_develop ### 打开问题/ PR 我们将使用Issues和Pull Requests作为跟踪器 -[GitHub Issues](https://github.com/apache/incubator-eventmesh/issues) -[Pull Requests](https://github.com/apache/incubator-eventmesh/pulls) +- [GitHub Issues](https://github.com/apache/incubator-eventmesh/issues) +- [Pull Requests](https://github.com/apache/incubator-eventmesh/pulls) -如果您在文档中发现拼写错误,在代码中发现错误,想要新功能或提出建议, 您可以提出问题[在GitHub上打开问题](https://github.com/apache/incubator-eventmesh/issues/new) -请按照问题模板中的准则消息进行操作。 +如果您发现新的Bug,想要新功能或提出新当建议,您可以在GitHub上[创建Issue](https://github.com/apache/incubator-eventmesh/issues/new) ,请按照Issue模板中的准则进行操作。 +如果您在文档中发现拼写错误,或者发现代码中存在可以进行微小的优化的地方,您可以无需创建Issue, 直接提交一个PR。 如果您想贡献,请遵循[贡献工作流程](#github-workflow)并创建一个新的拉取请求。 如果您的PR包含较大的更改,例如组件重构或新组件,请写详细文档 有关其设计和使用的信息。 +对于PR的标题请依照[ISSUE #xx]进行开头,如果是细小的改动请以[MINOR]进行开头。 -请注意,单个拉取请求不应太大。如果需要进行重大更改,最好将更改分开 到一些个人PR。 +【注意】: 单个PR不应太大。如果需要进行重大更改,最好将更改分开 到一些个人PR。 -### 代码审查 +### PR审查 -所有代码应由一个或多个committer进行良好的审查。一些原则: +所有PR应由一个或多个committer进行良好的审查。一些原则: - 可读性: 重要代码应有详细记录。符合我们的[代码风格](./style/checkStyle.xml) - 优雅: 新功能,类或组件应经过精心设计 @@ -78,10 +79,18 @@ git rebase upstream_develop EventMesh遵循[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) 政策。 所有的源代码文件应该在文件头部添加Apache License header,EventMesh会使用[apache/skywalking-eyes](https://github.com/apache/skywalking-eyes) -对源代码文件头进行校验。EventMesh使用[Gradle-License-Report](https://github.com/jk1/Gradle-License-Report)插件 -检查第三方依赖,当你需要添加三方依赖时,你需要将新添加的依赖注册在tool/license/allowed-licenses.txt中,你可以通过执行`./gradlew clean checkLicense`命令可以判断当前是否有license尚未添加, +对源代码文件头进行校验。 + +EventMesh使用[check-dependencies.sh](tools/third-party-dependencies/check-dependencies.sh)脚本 +检查第三方依赖,当你需要添加三方依赖时,你需要将新添加的依赖注册在tool/license/known-dependencies.txt中, 同时新添加的三方库需要满足[Apache对于第三方的政策](https://apache.org/legal/resolved.html)。 -非常建议在需要添加三方依赖之前与EventMesh社区进行沟通。 + +当添加依赖时遇到问题时,社区PPMC会协助解决,非常建议在需要添加三方依赖之前与EventMesh社区进行沟通。 + +### PR合并 + +PR经过至少一个committer approve之后会由committer负责合并,在合并的时候,committer可以对commits信息进行修改,要求commits信息简洁明了,不重复。 +在合并时使用Squash and merge, 要求一个PR保留一个commits。对于大型多人协助的PR,使用Merge进行合并,在合并之前通过rebase修正commits。 ## 社区 diff --git a/README.md b/README.md index 94c3742db3..9e27b02873 100644 --- a/README.md +++ b/README.md @@ -1,144 +1,143 @@ -# Apache EventMesh (incubating) -[![CI status](https://github.com/apache/incubator-eventmesh/actions/workflows/ci.yml/badge.svg)](https://github.com/apache/incubator-eventmesh/actions/workflows/ci.yml) -[![CodeCov](https://codecov.io/gh/apache/incubator-eventmesh/branch/develop/graph/badge.svg)](https://codecov.io/gh/apache/incubator-eventmesh) -[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/apache/incubator-eventmesh.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/apache/incubator-eventmesh/context:java) -[![Total alerts](https://img.shields.io/lgtm/alerts/g/apache/incubator-eventmesh.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/apache/incubator-eventmesh/alerts/) -[![GitHub release](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/apache/incubator-eventmesh/releases) -[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) - -[点我查看中文版](README.zh-CN.md) - -![logo](docs/images/logo2.png) -## What is EventMesh? -EventMesh(incubating) is a dynamic event-driven application runtime used to decouple the application and backend middleware layer, which supports a wide range of use cases that encompass complex multi-cloud, widely distributed topologies using diverse technology stacks. - -![architecture1](docs/images/eventmesh-multi-runtime.png) - -**EventMesh Architecture:** - -![architecture1](docs/images/eventmesh-runtime2.png) - -**Components:** - -* **eventmesh-runtime** : an middleware to transmit events between event producers and consumers, support cloud native apps and microservices. -* **eventmesh-sdk-java** : currently supports HTTP and TCP protocols. -* **eventmesh-connector-api** : an api layer based on OpenMessaging api and SPI pluggin, which can be implemented by popular EventStores such as IMDG, Messaging Engine and OSS etc. -* **eventmesh-connector-plugin** : plugins for connector. -* **eventmesh-connector-standalone** : an implementation of eventmesh-connector-api, pub event to or sub event from InMemory as EventStore. -* **eventmesh-connector-rocketmq** : an implementation of eventmesh-connector-api, pub event to or sub event from RocketMQ as EventStore. -* **eventmesh-connector-kafka(WIP)** : an implementation of eventmesh-connector-api, pub event to or sub event from Kafka as EventStore. -* **eventmesh-connector-redis(WIP)** : an implementation of eventmesh-connector-api, pub event to or sub event from Redis as EventStore. -* **eventmesh-connector-defibus(WIP)** : an implementation of eventmesh-connector-api, pub event to or sub event from [DeFiBus](https://github.com/webankfintech/defibus) as EventStore -* **eventmesh-admin** : clients,topics,subscriptions and other management. -* **eventmesh-registry-plugin** : plugins for registry adapter. -* **eventmesh-security-plugin** : plugins for security adpater. -* **eventmesh-protocol-plugin** : plugins for protocol adapter. - -**Protocol:** - -The protocol of eventmesh is easier and more convenient, you can read more [here](docs/en/instructions/eventmesh-runtime-protocol.md) - -## Feature - -Event & Service -- [x] Pub/Sub -- [x] Request/Reply -- [ ] Event Streaming -- [ ] Event transaction -- [ ] At-least-once/at-most-once delivery guarantees - -Connector -- [x] RocketMQ -- [x] InMemory -- [ ] Federated -- [ ] Kafka -- [ ] Redis -- [ ] Pulsar -- [ ] RabbitMQ -- [ ] DeFiBus -- [ ] Cold storage (S3, Minio, SQL, key/value, etc...) - -Protocol -- [x] TCP -- [x] Http -- [ ] gRPC -- [ ] CloudEvents -- [ ] MQTT -- [ ] AsyncAPI - -SDK -- [x] Java -- [ ] C -- [ ] Go -- [ ] Python - -Deploy -- [x] Sidecar -- [x] Gateway -- [x] Docker - -Metrics -- [x] OpenTelemetry -- [x] Promethus exporter - -Tracing -- [x] OpenTelemetry -- [x] Zipkin exporter -- [ ] Skywalking - -Governance -- [x] Client management -- [ ] Topic management -- [ ] Metadata registry -- [x] Schema registry -- [ ] Dynamic config - -Choreography -- [ ] Servelss workflow -- [ ] Event function,triggers and bindings - -Security -- [ ] Auth -- [ ] ACL - -Runtime -- [ ] WebAssembly runtime - -## Quick Start -1. [Connector quickstart](https://rocketmq.apache.org/docs/quick-start/) (RocketMQ, ignore this step if use standalone). -2. [Runtime quickstart](docs/en/instructions/eventmesh-runtime-quickstart.md) or [Runtime quickstart with docker](docs/en/instructions/eventmesh-runtime-quickstart-with-docker.md). -3. [Java SDK examples](docs/en/instructions/eventmesh-sdk-java-quickstart.md). - -## Contributing -Contributions are always welcomed! Please see [CONTRIBUTING](CONTRIBUTING.md) for detailed guidelines. - -You can start with the issues labeled with good first issue. -[GitHub Issues](https://github.com/apache/incubator-eventmesh/issues) - -## Landscape -

-

-   -

-EventMesh enriches the CNCF CLOUD NATIVE Landscape. -

- -## License -[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation. - -## Community -| WeChat group | WeChat public account | -| :---------------------------------------: | :----------------------------------------------------: | -| ![wechat_qr](docs/images/mesh-helper.jpg) | ![wechat_official_qr](docs/images/wechat-official.png) | - - - - - -Mailing Lists: - -| Name | Description |Subscribe |Unsubscribe|Archive -| ---- | ---- |---- | ---- | ---- | -|Users |User support and questions mailing list| [Subscribe](mailto:users-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:users-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?users@eventmesh.apache.org)| -|Development |Development related discussions| [Subscribe](mailto:dev-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:dev-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?dev@eventmesh.apache.org)| -|Commits |All commits to repositories| [Subscribe](mailto:commits-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:commits-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?commits@eventmesh.apache.org)| +# Apache EventMesh (incubating) +[![CI status](https://github.com/apache/incubator-eventmesh/actions/workflows/ci.yml/badge.svg)](https://github.com/apache/incubator-eventmesh/actions/workflows/ci.yml) +[![CodeCov](https://codecov.io/gh/apache/incubator-eventmesh/branch/develop/graph/badge.svg)](https://codecov.io/gh/apache/incubator-eventmesh) +[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/apache/incubator-eventmesh.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/apache/incubator-eventmesh/context:java) +[![Total alerts](https://img.shields.io/lgtm/alerts/g/apache/incubator-eventmesh.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/apache/incubator-eventmesh/alerts/) +[![GitHub release](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/apache/incubator-eventmesh/releases) +[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) +[![Slack Status](https://img.shields.io/badge/slack-join_chat-white.svg?logo=slack&style=social)](https://join.slack.com/t/apacheeventmesh/shared_invite/zt-yx3n2ak7-HcVG98CDqb~7PwgoDzgfMA) + +[点我查看中文版](README.zh-CN.md) + +![logo](docs/images/logo2.png) +## What is EventMesh? +EventMesh(incubating) is a dynamic event-driven application runtime used to decouple the application and backend middleware layer, which supports a wide range of use cases that encompass complex multi-cloud, widely distributed topologies using diverse technology stacks. + +![architecture1](docs/images/eventmesh-multi-runtime.png) + +**EventMesh Architecture:** + +![architecture1](docs/images/eventmesh-runtime2.png) + +**Components:** + +* **eventmesh-runtime** : an middleware to transmit events between event producers and consumers, support cloud native apps and microservices. +* **eventmesh-sdk-java** : currently supports HTTP and TCP protocols. +* **eventmesh-connector-api** : an api layer based on OpenMessaging api and SPI pluggin, which can be implemented by popular EventStores such as IMDG, Messaging Engine and OSS etc. +* **eventmesh-connector-plugin** : plugins for connector. +* **eventmesh-connector-standalone** : an implementation of eventmesh-connector-api, pub event to or sub event from InMemory as EventStore. +* **eventmesh-connector-rocketmq** : an implementation of eventmesh-connector-api, pub event to or sub event from RocketMQ as EventStore. +* **eventmesh-connector-kafka(WIP)** : an implementation of eventmesh-connector-api, pub event to or sub event from Kafka as EventStore. +* **eventmesh-connector-redis(WIP)** : an implementation of eventmesh-connector-api, pub event to or sub event from Redis as EventStore. +* **eventmesh-connector-defibus(WIP)** : an implementation of eventmesh-connector-api, pub event to or sub event from [DeFiBus](https://github.com/webankfintech/defibus) as EventStore +* **eventmesh-admin** : clients,topics,subscriptions and other management. +* **eventmesh-registry-plugin** : plugins for registry adapter. +* **eventmesh-security-plugin** : plugins for security adpater. +* **eventmesh-protocol-plugin** : plugins for protocol adapter. + +**Protocol:** + +The protocol of eventmesh is easier and more convenient, you can read more [here](docs/en/instructions/eventmesh-runtime-protocol.md) + +## Feature + +Event & Service +- [x] Pub/Sub +- [x] Request/Reply +- [ ] Event Streaming +- [ ] Event transaction +- [ ] At-least-once/at-most-once delivery guarantees + +Store Connector +- [x] RocketMQ +- [x] InMemory +- [ ] Federated +- [ ] Kafka +- [ ] Redis +- [ ] Pulsar +- [ ] RabbitMQ +- [ ] DeFiBus +- [ ] Cold storage (S3, Minio, SQL, key/value, etc...) + +Protocol +- [x] TCP +- [x] Http +- [ ] gRPC +- [ ] CloudEvents +- [ ] MQTT +- [ ] WebSocket +- [ ] AMQP +- [ ] AsyncAPI + +SDK +- [x] Java +- [ ] C +- [ ] Go +- [ ] Python + +Deploy +- [x] Sidecar +- [x] Gateway +- [x] Docker + +Metrics +- [x] OpenTelemetry +- [x] Promethus exporter + +Tracing +- [x] OpenTelemetry +- [x] Zipkin exporter +- [ ] Skywalking + +Governance +- [x] Client management +- [ ] Topic management +- [ ] Metadata registry +- [ ] Schema registry +- [ ] Dynamic config + +Choreography +- [ ] Servelss workflow +- [ ] Event function,triggers and bindings + +Security +- [ ] Auth +- [ ] ACL + +Runtime +- [ ] WebAssembly runtime + +## Quick Start +1. [Store quickstart](docs/en/instructions/eventmesh-store-quickstart.md) +2. [Runtime quickstart](docs/en/instructions/eventmesh-runtime-quickstart.md) or [Runtime quickstart with docker](docs/en/instructions/eventmesh-runtime-quickstart-with-docker.md). +3. [Java SDK examples](docs/en/instructions/eventmesh-sdk-java-quickstart.md). + +## Contributing +Contributions are always welcomed! Please see [CONTRIBUTING](CONTRIBUTING.md) for detailed guidelines. + +You can start with the issues labeled with good first issue. +[GitHub Issues](https://github.com/apache/incubator-eventmesh/issues) + +## Landscape +

+

+   +

+EventMesh enriches the CNCF CLOUD NATIVE Landscape. +

+ +## License +[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation. + +## Community +| WeChat Assistant | WeChat public account | Slack | +| :----------------------------------------------------: | :----------------------------------------------------: | :----------------------------------------------------: | +| ![wechat_qr](docs/images/mesh-helper.jpg) | ![wechat_official_qr](docs/images/wechat-official.png) |[Join slack chat](https://join.slack.com/t/apacheeventmesh/shared_invite/zt-yx3n2ak7-HcVG98CDqb~7PwgoDzgfMA) | + +Mailing Lists: + +| Name | Description |Subscribe |Unsubscribe|Archive +| ---- | ---- |---- | ---- | ---- | +|Users |User support and questions mailing list| [Subscribe](mailto:users-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:users-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?users@eventmesh.apache.org)| +|Development |Development related discussions| [Subscribe](mailto:dev-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:dev-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?dev@eventmesh.apache.org)| +|Commits |All commits to repositories| [Subscribe](mailto:commits-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:commits-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?commits@eventmesh.apache.org)| diff --git a/README.zh-CN.md b/README.zh-CN.md index bea441be47..08ebe7c924 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -36,7 +36,7 @@ EventMesh是一个动态的云原生事件驱动架构基础设施,用于分 **通信协议:** -eventmesh的通信协议更加简洁方便,详细内容,阅读更多[这里](docs/cn/instructions/eventmesh-runtime-protocol.zh-CN.md) +eventmesh的通信协议更加简洁方便,详细内容,阅读更多[这里](docs/cn/instructions/eventmesh-runtime-protocol.md) ## RoadMap | version | feature | diff --git a/build.gradle b/build.gradle index aa6074c715..9dc04941b8 100644 --- a/build.gradle +++ b/build.gradle @@ -35,6 +35,15 @@ buildscript { } } +//Remove doclint warnings that pollute javadoc logs when building with java8 +if(JavaVersion.current().isJava8()){ + allprojects { + tasks.withType(Javadoc){ + options.addStringOption('xdoclint:none','-quiet') + } + } +} + allprojects { apply plugin: 'java' apply plugin: "eclipse" @@ -48,7 +57,6 @@ allprojects { apply plugin: "java-library" apply plugin: 'signing' apply plugin: 'checkstyle' - apply plugin: 'com.github.jk1.dependency-license-report' [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8' @@ -60,26 +68,10 @@ allprojects { delete 'out' } - if ((project.findProperty("snapshot") instanceof String) && (Boolean.valueOf(project.property("snapshot")))) { + if ((project.findProperty("snapshot") instanceof String) && (Boolean.valueOf(project.property("snapshot") as boolean))) { version = version + "-SNAPSHOT" } - licenseReport { - allowedLicensesFile = new File("build/license/allowed-licenses.json") - } - - checkLicense.doFirst { - new File("build/license").mkdirs() - new File("build/license/allowed-licenses.json").createNewFile() - - def writer = new File("build/license/allowed-licenses.json").newPrintWriter() - new File("tool/license/allowed-licenses.txt").filterLine { - String line -> line.trim().length() != 0 && !line.startsWith("#") - }.writeTo(writer) - writer.flush() - writer.close() - } - checkstyle { toolVersion = '9.0' ignoreFailures = false @@ -153,6 +145,15 @@ task installPlugin() { }) } +task printProjects() { + getAllprojects().forEach(subProject -> { + if ("EventMesh".equals(subProject.getName())) { + return + } + println String.format("%s-%s.jar", subProject.getName(), subProject.getVersion()) + }) +} + subprojects { apply plugin: "io.spring.dependency-management" @@ -247,6 +248,7 @@ subprojects { new File("${projectDir}/dist/apps").mkdirs() new File("${projectDir}/dist/conf").mkdirs() new File("${projectDir}/dist/lib").mkdirs() + new File("${projectDir}/dist/licenses").mkdirs() } Set rootProject = ["eventmesh-admin", "eventmesh-common", @@ -298,6 +300,10 @@ subprojects { from "${projectDir}/dist/conf" } } + copy { + into "${rootDir}/dist/licenses" + from "${rootDir}/tools/third-party-licenses/licenses" + } } } @@ -402,17 +408,15 @@ subprojects { dependencies { dependency "org.apache.commons:commons-lang3:3.6" dependency "org.apache.commons:commons-collections4:4.1" - dependency "commons-io:commons-io:2.4" dependency "org.apache.commons:commons-text:1.9" - dependency "com.google.guava:guava:29.0-jre" + dependency "com.google.guava:guava:29.0-jre" + dependency "org.slf4j:slf4j-api:1.7.30" - dependency "org.apache.logging.log4j:log4j-api:2.13.3" - dependency "org.apache.logging.log4j:log4j-core:2.13.3" - dependency "org.apache.logging.log4j:log4j-core:2.13.3" - dependency "org.apache.logging.log4j:log4j-slf4j-impl:2.13.3" - dependency "org.apache.logging.log4j:log4j-web:2.13.3" + dependency "org.apache.logging.log4j:log4j-api:2.16.0" + dependency "org.apache.logging.log4j:log4j-core:2.16.0" + dependency "org.apache.logging.log4j:log4j-slf4j-impl:2.16.0" dependency "com.lmax:disruptor:3.4.2" @@ -435,6 +439,8 @@ subprojects { dependency 'io.opentelemetry:opentelemetry-exporter-prometheus:1.3.0-alpha' dependency 'io.prometheus:simpleclient:0.8.1' dependency 'io.prometheus:simpleclient_httpserver:0.8.1' + dependency 'io.opentelemetry:opentelemetry-exporter-zipkin:1.3.0' + dependency 'io.opentelemetry:opentelemetry-semconv:1.3.0-alpha' dependency "io.openmessaging:openmessaging-api:2.2.1-pubsub" @@ -442,6 +448,7 @@ subprojects { dependency "com.mebigfatguy.fb-contrib:fb-contrib:7.4.7" dependency "org.springframework.boot:spring-boot-starter-web:2.1.6.RELEASE" + dependency "io.openmessaging:registry-server:0.0.1" dependency "junit:junit:4.12" dependency "com.github.stefanbirkner:system-rules:1.16.1" @@ -452,6 +459,12 @@ subprojects { dependency "org.powermock:powermock-api-mockito2:2.0.2" dependency "io.cloudevents:cloudevents-core:2.2.0" + dependency "io.cloudevents:cloudevents-json-jackson:2.2.0" + + dependency "io.grpc:grpc-protobuf:1.15.0" + dependency "io.grpc:grpc-stub:1.15.0" + dependency "io.grpc:grpc-netty:1.15.0" + dependency "io.grpc:grpc-netty-shaded:1.15.0" } } } \ No newline at end of file diff --git a/docker/eventmesh-rocketmq/Dockerfile b/docker/eventmesh-rocketmq/Dockerfile index 5b61cc4f5d..fe9fe514ed 100644 --- a/docker/eventmesh-rocketmq/Dockerfile +++ b/docker/eventmesh-rocketmq/Dockerfile @@ -23,7 +23,7 @@ MAINTAINER mikexue mike_xwm@126.com WORKDIR /data RUN mkdir /data/app -ADD EventMesh_1.2.0-SNAPSHOT.tar.gz /data/app/eventmesh +ADD EventMesh_1.3.0-SNAPSHOT.tar.gz /data/app/eventmesh WORKDIR /data/app/eventmesh/bin EXPOSE 10000 diff --git a/docs/cn/features/https.md b/docs/cn/features/https.md index 4c30527469..a100ba3977 100644 --- a/docs/cn/features/https.md +++ b/docs/cn/features/https.md @@ -17,12 +17,12 @@ config env varible ``` //创建producer -LiteClientConfig liteClientConfig = new liteClientConfig(); +LiteClientConfig eventMeshHttpClientConfig = new eventMeshHttpClientConfig(); ... //设置开启TLS -liteClientConfig.setUseTls(true); -LiteProducer producer = new LiteProducer(liteClientConfig); +eventMeshHttpClientConfig.setUseTls(true); +LiteProducer producer = new LiteProducer(eventMeshHttpClientConfig); //配置环境变量 diff --git a/docs/cn/features/spi.md b/docs/cn/features/spi.md index b990d5956e..7499e655b1 100644 --- a/docs/cn/features/spi.md +++ b/docs/cn/features/spi.md @@ -101,7 +101,7 @@ public class RocketMQProducerImpl implements MeshMQProducer { ``` 同时,还需要在eventmesh-connector-rocketmq模块中resource/META-INF/eventmesh目录下创建文件名为SPI接口全限定名的文件 -org.apache.eventmesh.api.producer.MeshMQProducer +org.apache.eventmesh.api.producer.Producer 文件内容为扩展实例名和对应的实例全类名 diff --git a/docs/cn/instructions/eventmesh-runtime-quickstart.md b/docs/cn/instructions/eventmesh-runtime-quickstart.md index d0982a7c47..990334d7cc 100644 --- a/docs/cn/instructions/eventmesh-runtime-quickstart.md +++ b/docs/cn/instructions/eventmesh-runtime-quickstart.md @@ -79,8 +79,7 @@ sh start.sh ``` - 文件加载:通过将插件安装到插件目录,EventMesh在运行时会根据条件自动加载插件目录下的插件,可以通过执行以下命令安装插件 ```shell -./gradlew clean jar dist -./gradlew installPlugin +./gradlew clean jar dist && ./gradlew installPlugin ``` ***2.3.2.2 使用插件*** diff --git a/docs/en/features/eventmesh-trace-design.md b/docs/en/features/eventmesh-trace-design.md new file mode 100644 index 0000000000..81e6c23b8a --- /dev/null +++ b/docs/en/features/eventmesh-trace-design.md @@ -0,0 +1,89 @@ +# eventmesh-HTTP-trace-design + +## Introduction + +[EventMesh(incubating)](https://github.com/apache/incubator-eventmesh) is a dynamic cloud-native eventing infrastructure. + +## An overview of OpenTelemetry + +OpenTelemetry is a collection of tools, APIs, and SDKs. You can use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) for analysis in order to understand your software's performance and behavior. + +## Requirements + +- set tracer +- different exporter +- start and end span in server + +## Design Details + +* SpanProcessor: BatchSpanProcessor + +* Exporter: log(default), would be changed from properties + +```java +// Configure the batch spans processor. This span processor exports span in batches. +BatchSpanProcessor batchSpansProcessor = + BatchSpanProcessor.builder(exporter) + .setMaxExportBatchSize(512) // set the maximum batch size to use + .setMaxQueueSize(2048) // set the queue size. This must be >= the export batch size + .setExporterTimeout( + 30, TimeUnit.SECONDS) // set the max amount of time an export can run before getting + // interrupted + .setScheduleDelay(5, TimeUnit.SECONDS) // set time between two different exports + .build(); +OpenTelemetrySdk.builder() + .setTracerProvider( + SdkTracerProvider.builder().addSpanProcessor(batchSpansProcessor).build()) + .build(); +``` + +1. When using the method 'init()' of the class "EventMeshHTTPServer", the class "AbstractHTTPServer” will get the tracer + +```java +super.openTelemetryTraceFactory = new OpenTelemetryTraceFactory(eventMeshHttpConfiguration); +super.tracer = openTelemetryTraceFactory.getTracer(this.getClass().toString()); +super.textMapPropagator = openTelemetryTraceFactory.getTextMapPropagator(); +``` + +2. then the trace in class "AbstractHTTPServer” will work. + +## Problems + +#### How to set different exporter in class 'OpenTelemetryTraceFactory'?(Solved) + +After I get the exporter type from properties, how to deal with it. + +The 'logExporter' only needs to new it. + +But the 'zipkinExporter' needs to new and use the "getZipkinExporter()" method. + +## Solutions +#### Solution of different exporter +Use reflection to get an exporter. + +First of all, different exporter must implement the interface 'EventMeshExporter'. + +Then we get the exporter name from the configuration and reflect to the class. +```java +//different spanExporter +String exporterName = configuration.eventMeshTraceExporterType; +//use reflection to get spanExporter +String className = String.format("org.apache.eventmesh.runtime.exporter.%sExporter",exporterName); +EventMeshExporter eventMeshExporter = (EventMeshExporter) Class.forName(className).newInstance(); +spanExporter = eventMeshExporter.getSpanExporter(configuration); +``` + +Additional, this will surround with try catch.If the specified exporter cannot be obtained successfully, the default exporter log will be used instead + +#### Improvement of different exporter + +SPI(To be completed) + + +## Appendix + +#### References + +https://github.com/open-telemetry/docs-cn/blob/main/QUICKSTART.md + +https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/netty diff --git a/docs/en/features/https.md b/docs/en/features/https.md index 8f928c135c..0ef6b5aa97 100644 --- a/docs/en/features/https.md +++ b/docs/en/features/https.md @@ -18,11 +18,11 @@ config env varible ``` // create producer -LiteClientConfig liteClientConfig = new liteClientConfig(); +LiteClientConfig eventMeshHttpClientConfig = new eventMeshHttpClientConfig(); ... // enable TLS -liteClientConfig.setUseTls(true); -LiteProducer producer = new LiteProducer(liteClientConfig); +eventMeshHttpClientConfig.setUseTls(true); +LiteProducer producer = new LiteProducer(eventMeshHttpClientConfig); config env varible diff --git a/docs/en/features/spi.md b/docs/en/features/spi.md index 1c26d17ed5..af1d62725e 100644 --- a/docs/en/features/spi.md +++ b/docs/en/features/spi.md @@ -105,7 +105,7 @@ public class RocketMQProducerImpl implements MeshMQProducer { At the same time, we need to create a file with the full qualified name of the SPI interface under the resource/META-INF/eventmesh directory in the eventmesh-connector-rocketmq module. -org.apache.eventmesh.api.producer.MeshMQProducer +org.apache.eventmesh.api.producer.Producer The content of the file is the extension instance name and the corresponding instance full class name diff --git a/docs/en/instructions/eventmesh-runtime-quickstart.md b/docs/en/instructions/eventmesh-runtime-quickstart.md index a35ebbd3b1..2684c150c0 100644 --- a/docs/en/instructions/eventmesh-runtime-quickstart.md +++ b/docs/en/instructions/eventmesh-runtime-quickstart.md @@ -69,8 +69,7 @@ There are two ways to install the plugin: - Install from files: By installing the plugin into the plugin directory, EventMesh will automatically load the plugins in the plugin directory according to the conditions when EventMesh running, you can install the plugins by executing the following command. ```shell -./gradlew clean jar dist -./gradlew installPlugin +./gradlew clean jar dist && ./gradlew installPlugin ``` ***2.3.1.2 Use Plugin*** diff --git a/docs/en/instructions/eventmesh-store-quickstart.md b/docs/en/instructions/eventmesh-store-quickstart.md index 74158e85fc..2c0df05600 100644 --- a/docs/en/instructions/eventmesh-store-quickstart.md +++ b/docs/en/instructions/eventmesh-store-quickstart.md @@ -8,49 +8,19 @@ Gradle at least 5.6, eg 5.6.* 4g+ free disk for eventmesh-store server ``` +### Standalone-connector +No need a third-party store. -### download sources +### RocketMQ-connector +you can reference https://rocketmq.apache.org/docs/quick-start/ -download source code from [https://github.com/WeBankFinTech/DeFiBus](https://github.com/WeBankFinTech/DeFiBus) -You will get **DefiBus-master.zip** +and "One-click" build script is on going. -### build sources +### Kafka-connector +WIP -The eventmesh-store takes DeFiBus for example at the following parts, because eventmesh depends on defibus as store layer -by default, other implements such as Rocketmq etc. is coming soon. - -``` -unzip DefiBus-master.zip -cd /*YOUR DEPLOY PATH*/DefiBus-master -gradle clean dist tar -x test -``` - -You will get **DeFiBus_1.0.0.tar.gz** in directory /* YOUR DEPLOY PATH */DefiBus-master/build - -### Deployment - -- deploy DeFiBusNamesrv - -``` -upload DeFiBus_1.0.0.tar.gz -tar -zxvf DeFiBus_1.0.0.tar.gz -cd bin -sh runnamesrv.sh -``` - -If you see "Thre Name Server boot success" in ../logs/namesrv.log, you setup DeFiBus Namesrv successfully. - -- deploy DeFiBusBroker - -``` -upload DeFiBus_1.0.0.tar.gz -tar -zxvf DeFiBus_1.0.0.tar.gz -cd conf -config your broker.properties -cd ../bin -sh runbroker.sh -``` - -If you see "The broker \[YOUR-BROKER-NAME, IP:PORT\] boot success." in ../logs/broker.log, you setup eventmesh-store -successfully. +### Redis-connector +WIP +### DeFiBus-connector +WIP diff --git a/eventmesh-admin/README.md b/eventmesh-admin/README.md index 84f80470d8..f97d2a937d 100644 --- a/eventmesh-admin/README.md +++ b/eventmesh-admin/README.md @@ -4,10 +4,10 @@ EventMesh Administration Module for EventMesh. It manages Admin Service, Configu ## Administration Client Manager APIs -### POST /clientmanage/topics/ +### POST /topicmanage - Create a new topic if does not exist - Exposed POST endpoint to create a new topic if it does not exist. - * Url - http://localhost:8081/clientmanage/topics/ + * Url - http://localhost:8081/topicmanage * sample request payload ```json { @@ -23,12 +23,12 @@ EventMesh Administration Module for EventMesh. It manages Admin Service, Configu "created_time": "2021-09-03", } ``` -### DELETE /clientmanage/topics/(string: topic)/ +### DELETE /topicmanage/(string: topic) - Delete a specific topic. - Exposed DELETE endpoint to remove a specific topic * URL - ```url - http://localhost:8081/clientmanage/topics/mytopic1 + http://localhost:8081/topicmanage/mytopic1 ``` * Response - @@ -39,12 +39,12 @@ EventMesh Administration Module for EventMesh. It manages Admin Service, Configu } ``` -### GET /clientmanage/topics +### GET /topicmanage - Retrieve a list of topics - Exposed GET endpoint to retrieve all topics * URL - ```url - http://localhost:8081/clientmanage/topics + http://localhost:8081/topicmanage ``` * Response diff --git a/eventmesh-admin/build.gradle b/eventmesh-admin/build.gradle index 2bbbee28ff..0741bc6d52 100644 --- a/eventmesh-admin/build.gradle +++ b/eventmesh-admin/build.gradle @@ -15,5 +15,22 @@ * limitations under the License. */ -dependencies { +task copyEventMeshAdmin(dependsOn: ['jar']) { + doFirst { + new File(projectDir, '../eventmesh-admin/dist/apps').mkdir() + new File(projectDir, '../dist/admin/').mkdirs() + } + doLast { + copy { + into('../eventmesh-admin/dist/apps/') + from project.jar.getArchivePath() + exclude { + "eventmesh-admin-${version}.jar" + } + } + copy { + into '../dist/admin' + from "../eventmesh-admin/dist/apps/eventmesh-admin-rocketmq-${version}.jar" + } + } } \ No newline at end of file diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/build.gradle b/eventmesh-admin/eventmesh-admin-rocketmq/build.gradle new file mode 100644 index 0000000000..1217b33818 --- /dev/null +++ b/eventmesh-admin/eventmesh-admin-rocketmq/build.gradle @@ -0,0 +1,30 @@ +/* + * Licensed 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. + */ + + +dependencies { + compileOnly project(":eventmesh-common") + + implementation "org.apache.httpcomponents:httpclient" + implementation "com.fasterxml.jackson.core:jackson-databind" + implementation "com.fasterxml.jackson.core:jackson-core" + implementation "com.fasterxml.jackson.core:jackson-annotations" + + implementation project(":eventmesh-connector-plugin:eventmesh-connector-api") + + testImplementation project(":eventmesh-connector-plugin:eventmesh-connector-api") +} diff --git a/eventmesh-registry-plugin/eventmesh-registry-namesrv/gradle.properties b/eventmesh-admin/eventmesh-admin-rocketmq/gradle.properties similarity index 95% rename from eventmesh-registry-plugin/eventmesh-registry-namesrv/gradle.properties rename to eventmesh-admin/eventmesh-admin-rocketmq/gradle.properties index ace94b43e0..3d49f4c756 100644 --- a/eventmesh-registry-plugin/eventmesh-registry-namesrv/gradle.properties +++ b/eventmesh-admin/eventmesh-admin-rocketmq/gradle.properties @@ -14,5 +14,4 @@ # limitations under the License. # -pluginType=registry -pluginName=namesrv \ No newline at end of file +rocketmq_version=4.7.1 \ No newline at end of file diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/OpenSchemaExceptionHandler.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/controller/AdminController.java similarity index 55% rename from eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/OpenSchemaExceptionHandler.java rename to eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/controller/AdminController.java index eebc97964b..8932afd5cb 100644 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/OpenSchemaExceptionHandler.java +++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/controller/AdminController.java @@ -14,17 +14,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.eventmesh.schema.registry.server.exception; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; +package org.apache.eventmesh.admin.rocketmq.controller; -@ControllerAdvice -public class OpenSchemaExceptionHandler { +import org.apache.eventmesh.admin.rocketmq.handler.TopicsHandler; - @ExceptionHandler(value = OpenSchemaException.class) - public ResponseEntity exceptionHandler(OpenSchemaException e){ - return ResponseEntity.status(e.getErr_status().value()).body(new ErrorResponse(e.getErr_code(), e.getErr_message())); +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.sun.net.httpserver.HttpServer; + +public class AdminController { + + private static final Logger logger = LoggerFactory.getLogger(AdminController.class); + + public AdminController() { + } + + public void run(HttpServer server) throws IOException { + + server.createContext("/topicmanage", new TopicsHandler()); + + logger.info("EventMesh-Admin Controller server context created successfully"); } } diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/handler/TopicsHandler.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/handler/TopicsHandler.java new file mode 100644 index 0000000000..345f4bca30 --- /dev/null +++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/handler/TopicsHandler.java @@ -0,0 +1,108 @@ +/* + * Licensed 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.eventmesh.admin.rocketmq.handler; + +import org.apache.eventmesh.admin.rocketmq.request.TopicCreateRequest; +import org.apache.eventmesh.admin.rocketmq.response.TopicResponse; +import org.apache.eventmesh.admin.rocketmq.util.JsonUtils; +import org.apache.eventmesh.admin.rocketmq.util.NetUtils; +import org.apache.eventmesh.admin.rocketmq.util.RequestMapping; + +import org.apache.commons.lang3.StringUtils; + +import java.io.IOException; +import java.io.OutputStream; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; + +public class TopicsHandler implements HttpHandler { + private static final Logger logger = LoggerFactory.getLogger(TopicsHandler.class); + + @Override + public void handle(HttpExchange httpExchange) throws IOException { + + // create a new topic + if (RequestMapping.postMapping("/topicmanage", httpExchange)) { + createTopicHandler(httpExchange); + return; + } + + OutputStream out = httpExchange.getResponseBody(); + httpExchange.sendResponseHeaders(500, 0); + String result = String.format("Please check your request url"); + logger.error(result); + out.write(result.getBytes()); + return; + } + + public void createTopicHandler(HttpExchange httpExchange) throws IOException { + String result = ""; + OutputStream out = httpExchange.getResponseBody(); + try { + String params = NetUtils.parsePostBody(httpExchange); + TopicCreateRequest topicCreateRequest = + JsonUtils.toObject(params, TopicCreateRequest.class); + String topic = topicCreateRequest.getName(); + + if (StringUtils.isBlank(topic)) { + result = "Create topic failed. Parameter topic not found."; + logger.error(result); + out.write(result.getBytes()); + return; + } + + //TBD: A new rocketmq service will be implemented for creating topics + TopicResponse topicResponse = null; + if (topicResponse != null) { + logger.info("create a new topic: {}", topic); + httpExchange.getResponseHeaders().add("Content-Type", "appication/json"); + httpExchange.sendResponseHeaders(200, 0); + result = JsonUtils.toJson(topicResponse); + logger.info(result); + out.write(result.getBytes()); + return; + } else { + httpExchange.sendResponseHeaders(500, 0); + result = String.format("create topic failed! Server side error"); + logger.error(result); + out.write(result.getBytes()); + return; + } + } catch (Exception e) { + httpExchange.getResponseHeaders().add("Content-Type", "appication/json"); + httpExchange.sendResponseHeaders(500, 0); + result = String.format("create topic failed! Server side error"); + logger.error(result); + out.write(result.getBytes()); + return; + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + logger.warn("out close failed...", e); + } + } + } + } + +} diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/request/TopicCreateRequest.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/request/TopicCreateRequest.java new file mode 100644 index 0000000000..7adaa77cd2 --- /dev/null +++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/request/TopicCreateRequest.java @@ -0,0 +1,47 @@ +/* + * Licensed 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.eventmesh.admin.rocketmq.request; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonIgnoreProperties(ignoreUnknown = true) +public class TopicCreateRequest { + + private String name; + + @JsonCreator + public TopicCreateRequest(@JsonProperty("name") String topic) { + super(); + this.name = topic; + } + + @JsonProperty("name") + public String getName() { + return this.name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + +} diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/response/TopicResponse.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/response/TopicResponse.java new file mode 100644 index 0000000000..1dde496bcb --- /dev/null +++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/response/TopicResponse.java @@ -0,0 +1,64 @@ +/* + * Licensed 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.eventmesh.admin.rocketmq.response; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class TopicResponse { + + private String topic; + private String createdTime; + + @JsonCreator + public TopicResponse(@JsonProperty("topic") String topic, + @JsonProperty("created_time") String createdTime) { + super(); + this.topic = topic; + this.createdTime = createdTime; + } + + @JsonProperty("topic") + public String getTopic() { + return this.topic; + } + + @JsonProperty("topic") + public void setTopic(String topic) { + this.topic = topic; + } + + @JsonProperty("created_time") + public String getCreatedTime() { + return createdTime; + } + + @JsonProperty("created_time") + public void setCreatedTime(String createdTime) { + this.createdTime = createdTime; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("TopicResponse {topic=" + this.topic + ","); + sb.append("created_time=" + this.createdTime + "}"); + return sb.toString(); + } + +} diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/JsonUtils.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/JsonUtils.java new file mode 100644 index 0000000000..69455c5db5 --- /dev/null +++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/JsonUtils.java @@ -0,0 +1,72 @@ +/* + * Licensed 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.eventmesh.admin.rocketmq.util; + +import java.io.IOException; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +public class JsonUtils { + + private static ObjectMapper objectMapper; + + static { + objectMapper = new ObjectMapper(); + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); + } + + public static byte[] serialize(String topic, Class data) throws JsonProcessingException { + if (data == null) { + return null; + } + return objectMapper.writeValueAsBytes(data); + } + + public static String toJson(Object obj) throws JsonProcessingException { + if (obj == null) { + return null; + } + return objectMapper.writeValueAsString(obj); + } + + public static T toObject(String json, Class clazz) throws JsonProcessingException { + return objectMapper.readValue(json, clazz); + } + + public static T deserialize(Class clazz, byte[] bytes) throws IOException { + if (bytes == null || bytes.length == 0) { + return null; + } + + return objectMapper.readValue(bytes, clazz); + } + + public static T deserialize(Class clazz, String json) throws IOException { + if (json == null || json.length() == 0) { + return null; + } + + return objectMapper.readValue(json, clazz); + } +} diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/NetUtils.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/NetUtils.java new file mode 100644 index 0000000000..c6c7992d2e --- /dev/null +++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/NetUtils.java @@ -0,0 +1,51 @@ +/* + * Licensed 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.eventmesh.admin.rocketmq.util; + +import org.apache.http.Consts; + +import java.io.IOException; +import java.io.InputStreamReader; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.sun.net.httpserver.HttpExchange; + +public class NetUtils { + + private static final Logger logger = LoggerFactory.getLogger(NetUtils.class); + + public static String parsePostBody(HttpExchange exchange) + throws IOException { + StringBuilder body = new StringBuilder(); + if ("post".equalsIgnoreCase(exchange.getRequestMethod()) + || "put".equalsIgnoreCase(exchange.getRequestMethod())) { + try (InputStreamReader reader = + new InputStreamReader(exchange.getRequestBody(), Consts.UTF_8)) { + char[] buffer = new char[256]; + int read; + while ((read = reader.read(buffer)) != -1) { + body.append(buffer, 0, read); + } + } + } + return body.toString(); + } +} + diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/RequestMapping.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/RequestMapping.java new file mode 100644 index 0000000000..b093d3e9f3 --- /dev/null +++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/RequestMapping.java @@ -0,0 +1,60 @@ +/* + * Licensed 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.eventmesh.admin.rocketmq.util; + +import com.sun.net.httpserver.HttpExchange; + +public class RequestMapping { + + public static boolean postMapping(String value, HttpExchange httpExchange) { + if ("post".equalsIgnoreCase(httpExchange.getRequestMethod())) { + String requestUri = httpExchange.getRequestURI().getPath(); + UrlMappingPattern matcher = new UrlMappingPattern(value); + return matcher.matches(requestUri); + } + return false; + } + + public static boolean getMapping(String value, HttpExchange httpExchange) { + if ("get".equalsIgnoreCase(httpExchange.getRequestMethod())) { + String requestUri = httpExchange.getRequestURI().getPath(); + UrlMappingPattern matcher = new UrlMappingPattern(value); + return matcher.matches(requestUri); + } + return false; + } + + public static boolean putMapping(String value, HttpExchange httpExchange) { + if ("put".equalsIgnoreCase(httpExchange.getRequestMethod())) { + String requestUri = httpExchange.getRequestURI().getPath(); + UrlMappingPattern matcher = new UrlMappingPattern(value); + return matcher.matches(requestUri); + } + return false; + } + + public static boolean deleteMapping(String value, HttpExchange httpExchange) { + if ("delete".equalsIgnoreCase(httpExchange.getRequestMethod())) { + String requestUri = httpExchange.getRequestURI().getPath(); + UrlMappingPattern matcher = new UrlMappingPattern(value); + return matcher.matches(requestUri); + } + return false; + } + +} diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/UrlMappingPattern.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/UrlMappingPattern.java new file mode 100644 index 0000000000..0e31b13ca1 --- /dev/null +++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/UrlMappingPattern.java @@ -0,0 +1,109 @@ +/* + * Licensed 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.eventmesh.admin.rocketmq.util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class UrlMappingPattern { + + private static final String URL_PARAMETER_REGEX = "\\{(\\w*?)\\}"; + + private static final String URL_PARAMETER_MATCH_REGEX = + "\\([%\\\\w-.\\\\~!\\$&'\\\\(\\\\)\\\\*\\\\+,;=:\\\\[\\\\]@]+?\\)"; + + private static final Pattern URL_PARAMETER_PATTERN = Pattern.compile(URL_PARAMETER_REGEX); + + private static final String URL_FORMAT_REGEX = "(?:\\.\\{format\\})$"; + + private static final String URL_FORMAT_MATCH_REGEX = "(?:\\\\.\\([\\\\w%]+?\\))?"; + + private static final String URL_QUERY_STRING_REGEX = "(?:\\?.*?)?$"; + + private String urlMappingPattern; + + private Pattern compiledUrlMappingPattern; + + private List paramNames = new ArrayList(); + + public UrlMappingPattern(String pattern) { + super(); + setUrlMappingPattern(pattern); + compile(); + } + + public String getMappingPattern() { + return getUrlMappingPattern().replaceFirst(URL_FORMAT_REGEX, ""); + } + + private String getUrlMappingPattern() { + return urlMappingPattern; + } + + public Map extractPathParameterValues(String url) { + Matcher matcher = compiledUrlMappingPattern.matcher(url); + if (matcher.matches()) { + return extractParameters(matcher); + } + return null; + } + + public boolean matches(String url) { + return (extractPathParameterValues(url) != null); + } + + public void compile() { + acquireParamNames(); + String parsedPattern = + getUrlMappingPattern().replaceFirst(URL_FORMAT_REGEX, URL_FORMAT_MATCH_REGEX); + parsedPattern = parsedPattern.replaceAll(URL_PARAMETER_REGEX, URL_PARAMETER_MATCH_REGEX); + this.compiledUrlMappingPattern = Pattern.compile(parsedPattern + URL_QUERY_STRING_REGEX); + } + + private void acquireParamNames() { + Matcher m = URL_PARAMETER_PATTERN.matcher(getUrlMappingPattern()); + while (m.find()) { + paramNames.add(m.group(1)); + } + } + + private Map extractParameters(Matcher matcher) { + Map values = new HashMap(); + for (int i = 0; i < matcher.groupCount(); i++) { + String value = matcher.group(i + 1); + + if (value != null) { + values.put(paramNames.get(i), value); + } + } + return values; + } + + private void setUrlMappingPattern(String pattern) { + this.urlMappingPattern = pattern; + } + + public List getParamNames() { + return Collections.unmodifiableList(paramNames); + } +} diff --git a/eventmesh-common/build.gradle b/eventmesh-common/build.gradle index b552781545..d373fe1e71 100644 --- a/eventmesh-common/build.gradle +++ b/eventmesh-common/build.gradle @@ -16,47 +16,47 @@ */ dependencies { - api "org.apache.commons:commons-lang3" - api "org.apache.commons:commons-collections4" api "com.google.guava:guava" api "org.slf4j:slf4j-api" api "junit:junit" api "org.assertj:assertj-core" - - implementation "commons-io:commons-io" - implementation "org.apache.commons:commons-text" + api "org.apache.commons:commons-collections4" + api "org.apache.commons:commons-text" + api "org.apache.commons:commons-lang3" implementation "org.apache.logging.log4j:log4j-api" implementation "org.apache.logging.log4j:log4j-core" - implementation "org.apache.logging.log4j:log4j-core" implementation "org.apache.logging.log4j:log4j-slf4j-impl" - implementation "org.apache.logging.log4j:log4j-web" implementation "com.lmax:disruptor" - implementation "com.fasterxml.jackson.core:jackson-databind" - implementation "com.fasterxml.jackson.core:jackson-core" - implementation "com.fasterxml.jackson.core:jackson-annotations" + api "com.fasterxml.jackson.core:jackson-databind" + api "com.fasterxml.jackson.core:jackson-core" + api "com.fasterxml.jackson.core:jackson-annotations" implementation "org.apache.httpcomponents:httpclient" implementation "io.netty:netty-all" + implementation "io.grpc:grpc-protobuf:1.15.0" + implementation "io.grpc:grpc-stub:1.15.0" + implementation "com.github.stefanbirkner:system-rules" + compileOnly 'org.projectlombok:lombok:1.18.22' + annotationProcessor 'org.projectlombok:lombok:1.18.22' + + testCompileOnly 'org.projectlombok:lombok:1.18.22' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' + testImplementation "org.apache.commons:commons-lang3" - testImplementation "org.apache.commons:commons-collections4" - testImplementation "commons-io:commons-io" - testImplementation "org.apache.commons:commons-text" testImplementation "com.google.guava:guava" testImplementation "org.slf4j:slf4j-api" testImplementation "org.apache.logging.log4j:log4j-api" testImplementation "org.apache.logging.log4j:log4j-core" - testImplementation "org.apache.logging.log4j:log4j-core" testImplementation "org.apache.logging.log4j:log4j-slf4j-impl" - testImplementation "org.apache.logging.log4j:log4j-web" testImplementation "com.lmax:disruptor" @@ -69,7 +69,6 @@ dependencies { testImplementation "io.netty:netty-all" testImplementation "junit:junit" - testImplementation "com.github.stefanbirkner:system-rules" testImplementation "org.assertj:assertj-core" testImplementation "org.mockito:mockito-core" diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/Constants.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/Constants.java index c2457addc6..af222fd8c6 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/Constants.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/Constants.java @@ -29,6 +29,12 @@ public class Constants { public static final String HTTPS_PROTOCOL_PREFIX = "https://"; + public static final String PROTOCOL_TYPE = "protocoltype"; + + public static final String PROTOCOL_VERSION = "protocolversion"; + + public static final String PROTOCOL_DESC = "protocoldesc"; + public static final int DEFAULT_HTTP_TIME_OUT = 3000; public static final String EVENTMESH_MESSAGE_CONST_TTL = "ttl"; @@ -51,28 +57,30 @@ public class Constants { public static final String KEY_CONSTANTS_INSTANCE_DESC_PID = "pid"; - public static final String RMB_UNIQ_ID = "RMB_UNIQ_ID"; + public static final String RMB_UNIQ_ID = "rmbuniqid"; public static final String IDC_SEPERATER = "-"; - public static final String PROPERTY_MESSAGE_TIMEOUT = "TIMEOUT"; + public static final String PROPERTY_MESSAGE_TIMEOUT = "timeout"; + + public static final String PROPERTY_MESSAGE_SEARCH_KEYS = "searchkeys"; - public static final String PROPERTY_MESSAGE_SEARCH_KEYS = "SEARCH_KEYS"; + public static final String PROPERTY_MESSAGE_QUEUE_ID = "queueid"; - public static final String PROPERTY_MESSAGE_QUEUE_ID = "QUEUE_ID"; + public static final String PROPERTY_MESSAGE_QUEUE_OFFSET = "queueoffset"; - public static final String PROPERTY_MESSAGE_QUEUE_OFFSET = "QUEUE_OFFSET"; + public static final String PROPERTY_MESSAGE_DESTINATION = "destination"; - public static final String PROPERTY_MESSAGE_DESTINATION = "DESTINATION"; + public static final String PROPERTY_MESSAGE_MESSAGE_ID = "messageid"; - public static final String PROPERTY_MESSAGE_MESSAGE_ID = "MESSAGE_ID"; + public static final String PROPERTY_MESSAGE_BORN_HOST = "bornhost"; - public static final String PROPERTY_MESSAGE_BORN_HOST = "BORN_HOST"; + public static final String PROPERTY_MESSAGE_BORN_TIMESTAMP = "borntimestamp"; - public static final String PROPERTY_MESSAGE_BORN_TIMESTAMP = "BORN_TIMESTAMP"; + public static final String PROPERTY_MESSAGE_STORE_HOST = "storehost"; - public static final String PROPERTY_MESSAGE_STORE_HOST = "STORE_HOST"; + public static final String PROPERTY_MESSAGE_STORE_TIMESTAMP = "storetimestamp"; - public static final String PROPERTY_MESSAGE_STORE_TIMESTAMP = "STORE_TIMESTAMP"; + public static final String MESSAGE_PROP_SEPARATOR = "99"; } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshMessage.java new file mode 100644 index 0000000000..8fecc700fe --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshMessage.java @@ -0,0 +1,70 @@ +/* + * Licensed 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.eventmesh.common; + +import java.util.HashMap; +import java.util.Map; + +import lombok.Builder; +import lombok.Data; + +/** + * EventMesh message. + */ +@Builder +@Data +public class EventMeshMessage { + + private String bizSeqNo; + + private String uniqueId; + + private String topic; + + private String content; + + private Map prop; + + @Builder.Default + private final long createTime = System.currentTimeMillis(); + + public EventMeshMessage addProp(String key, String val) { + if (prop == null) { + prop = new HashMap<>(); + } + prop.put(key, val); + return this; + } + + public String getProp(String key) { + if (prop == null) { + return null; + } + return prop.get(key); + } + + public EventMeshMessage removePropIfPresent(String key) { + if (prop == null) { + + return this; + } + prop.remove(key); + return this; + } + +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/LiteMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/LiteMessage.java deleted file mode 100644 index 455dfc65d0..0000000000 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/LiteMessage.java +++ /dev/null @@ -1,131 +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 org.apache.eventmesh.common; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.lang3.time.DateFormatUtils; - -public class LiteMessage { - - private String bizSeqNo; - - private String uniqueId; - - private String topic; - - private String content; - - private Map prop; - - private long createTime = System.currentTimeMillis(); - - public LiteMessage() { - } - - public LiteMessage(String bizSeqno, String uniqueId, String topic, - String content) { - this.bizSeqNo = bizSeqno; - this.uniqueId = uniqueId; - this.topic = topic; - this.content = content; - } - - public Map getProp() { - return prop; - } - - public LiteMessage setProp(Map prop) { - this.prop = prop; - return this; - } - - public LiteMessage addProp(String key, String val) { - if (prop == null) { - prop = new HashMap(); - } - prop.put(key, val); - return this; - } - - public String getPropKey(String key) { - if (prop == null) { - return null; - } - return prop.get(key); - } - - public LiteMessage removeProp(String key) { - if (prop == null) { - return this; - } - prop.remove(key); - return this; - } - - public String getBizSeqNo() { - return bizSeqNo; - } - - public LiteMessage setBizSeqNo(String bizSeqNo) { - this.bizSeqNo = bizSeqNo; - return this; - } - - public String getUniqueId() { - return uniqueId; - } - - public LiteMessage setUniqueId(String uniqueId) { - this.uniqueId = uniqueId; - return this; - } - - public String getTopic() { - return topic; - } - - public LiteMessage setTopic(String topic) { - this.topic = topic; - return this; - } - - public String getContent() { - return content; - } - - public LiteMessage setContent(String content) { - this.content = content; - return this; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("liteMessage={") - .append("bizSeqNo=").append(bizSeqNo).append(",") - .append("uniqueId=").append(uniqueId).append(",") - .append("topic=").append(topic).append(",") - .append("content=").append(content).append(",") - .append("prop=").append(prop).append(",") - .append("createTime=").append(DateFormatUtils.format(createTime, Constants.DATE_FORMAT)) - .append("}"); - return sb.toString(); - } -} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java index 5be65297b3..319673d247 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java @@ -26,37 +26,32 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import com.google.common.util.concurrent.ThreadFactoryBuilder; + public class ThreadPoolFactory { public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, final String threadName) { return createThreadPoolExecutor(core, max, threadName, true); } - public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, final String threadName, final boolean isDaemon) { + public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, final String threadName, + final boolean isDaemon) { return createThreadPoolExecutor(core, max, new LinkedBlockingQueue(1000), threadName, isDaemon); } - public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, BlockingQueue blockingQueue, final String threadName, final boolean isDaemon) { - return new ThreadPoolExecutor(core, max, - 10 * 1000, TimeUnit.MILLISECONDS, blockingQueue, new ThreadFactory() { - - private AtomicInteger seq = new AtomicInteger(0); - - @Override - public Thread newThread(Runnable r) { - seq.incrementAndGet(); - Thread t = new Thread(r, threadName + seq.get()); - t.setDaemon(isDaemon); - return t; - } - }); + public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, BlockingQueue blockingQueue, + final String threadName, final boolean isDaemon) { + return new ThreadPoolExecutor(core, max, 10 * 1000, TimeUnit.MILLISECONDS, blockingQueue, + new ThreadFactoryBuilder().setNameFormat(threadName).setDaemon(isDaemon).build() + ); } public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, ThreadFactory threadFactory) { return createThreadPoolExecutor(core, max, new LinkedBlockingQueue(1000), threadFactory); } - public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, BlockingQueue blockingQueue, ThreadFactory threadFactory) { + public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, BlockingQueue blockingQueue, + ThreadFactory threadFactory) { return new ThreadPoolExecutor(core, max, 10 * 1000, TimeUnit.MILLISECONDS, blockingQueue, threadFactory); } @@ -77,7 +72,8 @@ public static ScheduledExecutorService createScheduledExecutor(int core, final S return createScheduledExecutor(core, threadName, true); } - public static ScheduledExecutorService createScheduledExecutor(int core, final String threadName, final boolean isDaemon) { + public static ScheduledExecutorService createScheduledExecutor(int core, final String threadName, + final boolean isDaemon) { return Executors.newScheduledThreadPool(core, new ThreadFactory() { private AtomicInteger ai = new AtomicInteger(0); diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java index 2c6b37d63c..33e9ce950e 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java @@ -20,7 +20,7 @@ import com.google.common.base.Preconditions; import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.common.IPUtil; +import org.apache.eventmesh.common.utils.IPUtils; public class CommonConfiguration { public String eventMeshEnv = "P"; @@ -32,6 +32,13 @@ public class CommonConfiguration { public String eventMeshSecurityPluginType = "security"; public int eventMeshPrometheusPort = 19090; public String eventMeshRegistryPluginType = "namesrv"; + public String eventMeshTraceExporterType = "Log"; + public int eventMeshTraceExporterMaxExportSize = 512; + public int eventMeshTraceExporterMaxQueueSize = 2048; + public int eventMeshTraceExporterExportTimeout = 30; + public int eventMeshTraceExporterExportInterval = 5; + public String eventMeshTraceExportZipkinIp = "localhost"; + public int eventMeshTraceExportZipkinPort = 9411; public String namesrvAddr = ""; public Integer eventMeshRegisterIntervalInMills = 10 * 1000; @@ -48,54 +55,125 @@ public CommonConfiguration(ConfigurationWrapper configurationWrapper) { public void init() { if (configurationWrapper != null) { - String eventMeshEnvStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ENV); - Preconditions.checkState(StringUtils.isNotEmpty(eventMeshEnvStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ENV)); + String eventMeshEnvStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ENV); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshEnvStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_ENV)); eventMeshEnv = StringUtils.deleteWhitespace(eventMeshEnvStr); - String sysIdStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SYSID); - Preconditions.checkState(StringUtils.isNotEmpty(sysIdStr) && StringUtils.isNumeric(sysIdStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SYSID)); + String sysIdStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SYSID); + Preconditions.checkState(StringUtils.isNotEmpty(sysIdStr) && StringUtils.isNumeric(sysIdStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_SYSID)); sysID = StringUtils.deleteWhitespace(sysIdStr); - String eventMeshClusterStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_CLUSTER); - Preconditions.checkState(StringUtils.isNotEmpty(eventMeshClusterStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_CLUSTER)); + String eventMeshClusterStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_CLUSTER); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshClusterStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_CLUSTER)); eventMeshCluster = StringUtils.deleteWhitespace(eventMeshClusterStr); - String eventMeshNameStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_NAME); - Preconditions.checkState(StringUtils.isNotEmpty(eventMeshNameStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_NAME)); + String eventMeshNameStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_NAME); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshNameStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_NAME)); eventMeshName = StringUtils.deleteWhitespace(eventMeshNameStr); - String eventMeshIDCStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_IDC); - Preconditions.checkState(StringUtils.isNotEmpty(eventMeshIDCStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_IDC)); - eventMeshIDC = StringUtils.deleteWhitespace(eventMeshIDCStr); + String eventMeshIdcStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_IDC); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshIdcStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_IDC)); + eventMeshIDC = StringUtils.deleteWhitespace(eventMeshIdcStr); - String eventMeshPrometheusPortStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_METRICS_PROMETHEUS_PORT); + String eventMeshPrometheusPortStr = + configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_METRICS_PROMETHEUS_PORT); if (StringUtils.isNotEmpty(eventMeshPrometheusPortStr)) { - eventMeshPrometheusPort = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshPrometheusPortStr)); + eventMeshPrometheusPort = + Integer.valueOf(StringUtils.deleteWhitespace(eventMeshPrometheusPortStr)); } - eventMeshServerIp = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_HOST_IP); + eventMeshServerIp = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_HOST_IP); if (StringUtils.isBlank(eventMeshServerIp)) { - eventMeshServerIp = IPUtil.getLocalAddress(); + eventMeshServerIp = IPUtils.getLocalAddress(); } - eventMeshConnectorPluginType = configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_CONNECTOR_PLUGIN_TYPE); - Preconditions.checkState(StringUtils.isNotEmpty(eventMeshConnectorPluginType), String.format("%s error", ConfKeys.KEYS_ENENTMESH_CONNECTOR_PLUGIN_TYPE)); + eventMeshConnectorPluginType = + configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_CONNECTOR_PLUGIN_TYPE); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshConnectorPluginType), + String.format("%s error", ConfKeys.KEYS_ENENTMESH_CONNECTOR_PLUGIN_TYPE)); - String eventMeshServerAclEnableStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SECURITY_ENABLED); + String eventMeshServerAclEnableStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SECURITY_ENABLED); if (StringUtils.isNotBlank(eventMeshServerAclEnableStr)) { - eventMeshServerSecurityEnable = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerAclEnableStr)); + eventMeshServerSecurityEnable = + Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerAclEnableStr)); } - eventMeshSecurityPluginType = configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_SECURITY_PLUGIN_TYPE); - Preconditions.checkState(StringUtils.isNotEmpty(eventMeshSecurityPluginType), String.format("%s error", ConfKeys.KEYS_ENENTMESH_SECURITY_PLUGIN_TYPE)); + eventMeshSecurityPluginType = + configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_SECURITY_PLUGIN_TYPE); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshSecurityPluginType), + String.format("%s error", ConfKeys.KEYS_ENENTMESH_SECURITY_PLUGIN_TYPE)); - String eventMeshServerRegistryEnableStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_REGISTRY_ENABLED); + String eventMeshServerRegistryEnableStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_REGISTRY_ENABLED); if (StringUtils.isNotBlank(eventMeshServerRegistryEnableStr)) { - eventMeshServerRegistryEnable = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerRegistryEnableStr)); + eventMeshServerRegistryEnable = + Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerRegistryEnableStr)); } - eventMeshRegistryPluginType = configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_REGISTRY_PLUGIN_TYPE); - Preconditions.checkState(StringUtils.isNotEmpty(eventMeshRegistryPluginType), String.format("%s error", ConfKeys.KEYS_ENENTMESH_REGISTRY_PLUGIN_TYPE)); + eventMeshRegistryPluginType = + configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_REGISTRY_PLUGIN_TYPE); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshRegistryPluginType), + String.format("%s error", ConfKeys.KEYS_ENENTMESH_REGISTRY_PLUGIN_TYPE)); + + String eventMeshTraceExporterTypeStr = + configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_TRACE_EXPORTER_TYPE); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshTraceExporterTypeStr), + String.format("%s error", ConfKeys.KEYS_ENENTMESH_TRACE_EXPORTER_TYPE)); + eventMeshTraceExporterType = + StringUtils.deleteWhitespace(eventMeshTraceExporterTypeStr); + + String eventMeshTraceExporterMaxExportSizeStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORTER_MAX_EXPORT_SIZE); + if (StringUtils.isNotEmpty(eventMeshTraceExporterMaxExportSizeStr)) { + eventMeshTraceExporterMaxExportSize = + Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTraceExporterMaxExportSizeStr)); + } + + String eventMeshTraceExporterMaxQueueSizeStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORTER_MAX_QUEUE_SIZE); + if (StringUtils.isNotEmpty(eventMeshTraceExporterMaxQueueSizeStr)) { + eventMeshTraceExporterMaxQueueSize = + Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTraceExporterMaxQueueSizeStr)); + } + + String eventMeshTraceExporterExportTimeoutStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORTER_EXPORT_TIMEOUT); + if (StringUtils.isNotEmpty(eventMeshTraceExporterExportTimeoutStr)) { + eventMeshTraceExporterExportTimeout = + Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTraceExporterExportTimeoutStr)); + } + + String eventMeshTraceExporterExportIntervalStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORTER_EXPORT_INTERVAL); + if (StringUtils.isNotEmpty(eventMeshTraceExporterExportIntervalStr)) { + eventMeshTraceExporterExportInterval = + Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTraceExporterExportIntervalStr)); + } + + String eventMeshTraceExportZipkinIpStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_IP); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshTraceExportZipkinIpStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_IP)); + eventMeshTraceExportZipkinIp = StringUtils.deleteWhitespace(eventMeshTraceExportZipkinIpStr); + + String eventMeshTraceExportZipkinPortStr = + configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_PORT); + if (StringUtils.isNotEmpty(eventMeshTraceExportZipkinPortStr)) { + eventMeshTraceExportZipkinPort = + Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTraceExportZipkinPortStr)); + } } } @@ -112,9 +190,11 @@ static class ConfKeys { public static String KEYS_EVENTMESH_SERVER_HOST_IP = "eventMesh.server.hostIp"; - public static String KEYS_EVENTMESH_SERVER_REGISTER_INTERVAL = "eventMesh.server.registry.registerIntervalInMills"; + public static String KEYS_EVENTMESH_SERVER_REGISTER_INTERVAL = + "eventMesh.server.registry.registerIntervalInMills"; - public static String KEYS_EVENTMESH_SERVER_FETCH_REGISTRY_ADDR_INTERVAL = "eventMesh.server.registry.fetchRegistryAddrIntervalInMills"; + public static String KEYS_EVENTMESH_SERVER_FETCH_REGISTRY_ADDR_INTERVAL = + "eventMesh.server.registry.fetchRegistryAddrIntervalInMills"; public static String KEYS_ENENTMESH_CONNECTOR_PLUGIN_TYPE = "eventMesh.connector.plugin.type"; @@ -127,5 +207,19 @@ static class ConfKeys { public static String KEYS_EVENTMESH_REGISTRY_ENABLED = "eventMesh.server.registry.enabled"; public static String KEYS_ENENTMESH_REGISTRY_PLUGIN_TYPE = "eventMesh.registry.plugin.type"; + + public static String KEYS_ENENTMESH_TRACE_EXPORTER_TYPE = "eventmesh.trace.exporter.type"; + + public static String KEYS_EVENTMESH_TRACE_EXPORTER_MAX_EXPORT_SIZE = "eventmesh.trace.exporter.max.export.size"; + + public static String KEYS_EVENTMESH_TRACE_EXPORTER_MAX_QUEUE_SIZE = "eventmesh.trace.exporter.max.queue.size"; + + public static String KEYS_EVENTMESH_TRACE_EXPORTER_EXPORT_TIMEOUT = "eventmesh.trace.exporter.export.timeout"; + + public static String KEYS_EVENTMESH_TRACE_EXPORTER_EXPORT_INTERVAL = "eventmesh.trace.exporter.export.interval"; + + public static String KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_IP = "eventmesh.trace.export.zipkin.ip"; + + public static String KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_PORT = "eventmesh.trace.export.zipkin.port"; } } \ No newline at end of file diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshException.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/exception/EventMeshException.java similarity index 87% rename from eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshException.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/exception/EventMeshException.java index bffa57e780..9dc45c29f9 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshException.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/exception/EventMeshException.java @@ -15,13 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.common; +package org.apache.eventmesh.common.exception; public class EventMeshException extends Exception { - public EventMeshException() { - } - public EventMeshException(String message) { super(message); } @@ -39,8 +36,6 @@ public EventMeshException(String message, Throwable cause, boolean enableSuppres } public EventMeshException(Integer errCode, String errMsg) { - super((new StringBuilder()).append(errCode) - .append("|") - .append(errMsg).toString()); + super(String.format("errorCode: %s, errorMessage: %s", errCode, errMsg)); } } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/loadbalance/WeightRandomLoadBalanceSelector.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/loadbalance/WeightRandomLoadBalanceSelector.java index 1fc239d608..835bc48382 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/loadbalance/WeightRandomLoadBalanceSelector.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/loadbalance/WeightRandomLoadBalanceSelector.java @@ -19,7 +19,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.RandomUtils; -import org.apache.eventmesh.common.EventMeshException; +import org.apache.eventmesh.common.exception.EventMeshException; import java.util.List; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/ProtocolTransportObject.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/ProtocolTransportObject.java new file mode 100644 index 0000000000..ca7c36626a --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/ProtocolTransportObject.java @@ -0,0 +1,31 @@ +/* + * Licensed 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.eventmesh.common.protocol; + +import org.apache.eventmesh.common.protocol.http.HttpCommand; + +import java.io.Serializable; + +/** + *
    + *
  • Tcp transport object{@link org.apache.eventmesh.common.protocol.tcp.Package}
  • + *
  • Http transport object{@link HttpCommand}
  • + *
+ */ +public interface ProtocolTransportObject extends Serializable { +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java new file mode 100644 index 0000000000..07bd66f968 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.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.eventmesh.common.protocol.grpc.common; + +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; + +public class EventMeshMessageWrapper implements ProtocolTransportObject { + + private EventMeshMessage eventMeshMessage; + + public EventMeshMessageWrapper(EventMeshMessage eventMeshMessage) { + this.eventMeshMessage = eventMeshMessage; + } + + public EventMeshMessage getMessage() { + return eventMeshMessage; + } +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java new file mode 100644 index 0000000000..62d171bc76 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java @@ -0,0 +1,40 @@ +/* + * Licensed 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.eventmesh.common.protocol.grpc.common; + +public class ProtocolKey { + + public static final String ENV = "env"; + public static final String IDC = "idc"; + public static final String SYS = "sys"; + public static final String PID = "pid"; + public static final String IP = "ip"; + public static final String USERNAME = "username"; + public static final String PASSWD = "passwd"; + public static final String LANGUAGE = "language"; + + public static final String PROTOCOL_TYPE = "protocoltype"; + public static final String PROTOCOL_VERSION = "protocolversion"; + public static final String PROTOCOL_DESC = "protocoldesc"; + + public static final String SEQ_NUM = "seqnum"; + public static final String UNIQUE_ID = "uniqueid"; + public static final String TTL = "ttl"; + public static final String PRODUCERGROUP = "producergroup"; + public static final String TAG = "tag"; +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java new file mode 100644 index 0000000000..3b930e1803 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java @@ -0,0 +1,68 @@ +/* + * Licensed 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.eventmesh.common.protocol.grpc.common; + +public enum StatusCode { + + SUCCESS("0", "success"), + OVERLOAD("1", "eventMesh overload, try later, "), + EVENTMESH_REQUESTCODE_INVALID("2", "requestCode can't be null, or must be number, "), + EVENTMESH_SEND_SYNC_MSG_ERR("3", "eventMesh send rr msg err, "), + EVENTMESH_WAITING_RR_MSG_ERR("4", "eventMesh waiting rr msg err, "), + EVENTMESH_PROTOCOL_HEADER_ERR("6", "eventMesh protocol[header] err, "), + EVENTMESH_PROTOCOL_BODY_ERR("7", "eventMesh protocol[body] err, "), + EVENTMESH_STOP("8", "eventMesh will stop or had stopped, "), + EVENTMESH_REJECT_BY_PROCESSOR_ERROR("9", "eventMesh reject by processor error, "), + EVENTMESH_BATCH_PRODUCER_STOPED_ERR("10", "eventMesh batch msg producer stopped, "), + EVENTMESH_SEND_BATCHLOG_MSG_ERR("17", "eventMesh send batchlog msg err, "), + EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR("11", "eventMesh batch msg speed over the limit, "), + EVENTMESH_PACKAGE_MSG_ERR("12", "eventMesh package msg err, "), + EVENTMESH_GROUP_PRODUCER_STOPED_ERR("13", "eventMesh group producer stopped, "), + EVENTMESH_SEND_ASYNC_MSG_ERR("14", "eventMesh send async msg err, "), + EVENTMESH_REPLY_MSG_ERR("15", "eventMesh reply msg err, "), + EVENTMESH_RUNTIME_ERR("16", "eventMesh runtime err, "), + EVENTMESH_SUBSCRIBE_ERR("17", "eventMesh subscribe err"), + EVENTMESH_UNSUBSCRIBE_ERR("18", "eventMesh unsubscribe err"), + EVENTMESH_HEARTBEAT_ERR("19", "eventMesh heartbeat err"), + EVENTMESH_ACL_ERR("20", "eventMesh acl err"); + + private String retCode; + + private String errMsg; + + StatusCode(String retCode, String errMsg) { + this.retCode = retCode; + this.errMsg = errMsg; + } + + public String getRetCode() { + return retCode; + } + + public void setRetCode(String retCode) { + this.retCode = retCode; + } + + public String getErrMsg() { + return errMsg; + } + + public void setErrMsg(String errMsg) { + this.errMsg = errMsg; + } +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java new file mode 100644 index 0000000000..12454c8ab5 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java @@ -0,0 +1,423 @@ +package org.apache.eventmesh.common.protocol.grpc.protos; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.15.0)", + comments = "Source: eventmesh-client.proto") +public final class ConsumerServiceGrpc { + + private ConsumerServiceGrpc() {} + + public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.ConsumerService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getSubscribeMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "subscribe", + requestType = Subscription.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getSubscribeMethod() { + io.grpc.MethodDescriptor getSubscribeMethod; + if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { + synchronized (ConsumerServiceGrpc.class) { + if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { + ConsumerServiceGrpc.getSubscribeMethod = getSubscribeMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.ConsumerService", "subscribe")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Subscription.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribe")) + .build(); + } + } + } + return getSubscribeMethod; + } + + private static volatile io.grpc.MethodDescriptor getSubscribeStreamMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "subscribeStream", + requestType = Subscription.class, + responseType = EventMeshMessage.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor getSubscribeStreamMethod() { + io.grpc.MethodDescriptor getSubscribeStreamMethod; + if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { + synchronized (ConsumerServiceGrpc.class) { + if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { + ConsumerServiceGrpc.getSubscribeStreamMethod = getSubscribeStreamMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.ConsumerService", "subscribeStream")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Subscription.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + EventMeshMessage.getDefaultInstance())) + .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribeStream")) + .build(); + } + } + } + return getSubscribeStreamMethod; + } + + private static volatile io.grpc.MethodDescriptor getUnsubscribeMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "unsubscribe", + requestType = Subscription.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getUnsubscribeMethod() { + io.grpc.MethodDescriptor getUnsubscribeMethod; + if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { + synchronized (ConsumerServiceGrpc.class) { + if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { + ConsumerServiceGrpc.getUnsubscribeMethod = getUnsubscribeMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.ConsumerService", "unsubscribe")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Subscription.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("unsubscribe")) + .build(); + } + } + } + return getUnsubscribeMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static ConsumerServiceStub newStub(io.grpc.Channel channel) { + return new ConsumerServiceStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static ConsumerServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new ConsumerServiceBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static ConsumerServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + return new ConsumerServiceFutureStub(channel); + } + + /** + */ + public static abstract class ConsumerServiceImplBase implements io.grpc.BindableService { + + /** + */ + public void subscribe(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getSubscribeMethod(), responseObserver); + } + + /** + */ + public void subscribeStream(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getSubscribeStreamMethod(), responseObserver); + } + + /** + */ + public void unsubscribe(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUnsubscribeMethod(), responseObserver); + } + + @Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getSubscribeMethod(), + asyncUnaryCall( + new MethodHandlers< + Subscription, + Response>( + this, METHODID_SUBSCRIBE))) + .addMethod( + getSubscribeStreamMethod(), + asyncServerStreamingCall( + new MethodHandlers< + Subscription, + EventMeshMessage>( + this, METHODID_SUBSCRIBE_STREAM))) + .addMethod( + getUnsubscribeMethod(), + asyncUnaryCall( + new MethodHandlers< + Subscription, + Response>( + this, METHODID_UNSUBSCRIBE))) + .build(); + } + } + + /** + */ + public static final class ConsumerServiceStub extends io.grpc.stub.AbstractStub { + private ConsumerServiceStub(io.grpc.Channel channel) { + super(channel); + } + + private ConsumerServiceStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected ConsumerServiceStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new ConsumerServiceStub(channel, callOptions); + } + + /** + */ + public void subscribe(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getSubscribeMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void subscribeStream(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncServerStreamingCall( + getChannel().newCall(getSubscribeStreamMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void unsubscribe(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class ConsumerServiceBlockingStub extends io.grpc.stub.AbstractStub { + private ConsumerServiceBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private ConsumerServiceBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected ConsumerServiceBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new ConsumerServiceBlockingStub(channel, callOptions); + } + + /** + */ + public Response subscribe(Subscription request) { + return blockingUnaryCall( + getChannel(), getSubscribeMethod(), getCallOptions(), request); + } + + /** + */ + public java.util.Iterator subscribeStream( + Subscription request) { + return blockingServerStreamingCall( + getChannel(), getSubscribeStreamMethod(), getCallOptions(), request); + } + + /** + */ + public Response unsubscribe(Subscription request) { + return blockingUnaryCall( + getChannel(), getUnsubscribeMethod(), getCallOptions(), request); + } + } + + /** + */ + public static final class ConsumerServiceFutureStub extends io.grpc.stub.AbstractStub { + private ConsumerServiceFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private ConsumerServiceFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected ConsumerServiceFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new ConsumerServiceFutureStub(channel, callOptions); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture subscribe( + Subscription request) { + return futureUnaryCall( + getChannel().newCall(getSubscribeMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture unsubscribe( + Subscription request) { + return futureUnaryCall( + getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_SUBSCRIBE = 0; + private static final int METHODID_SUBSCRIBE_STREAM = 1; + private static final int METHODID_UNSUBSCRIBE = 2; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final ConsumerServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(ConsumerServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @Override + @SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_SUBSCRIBE: + serviceImpl.subscribe((Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_SUBSCRIBE_STREAM: + serviceImpl.subscribeStream((Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UNSUBSCRIBE: + serviceImpl.unsubscribe((Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @Override + @SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class ConsumerServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + ConsumerServiceBaseDescriptorSupplier() {} + + @Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return EventmeshGrpc.getDescriptor(); + } + + @Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("ConsumerService"); + } + } + + private static final class ConsumerServiceFileDescriptorSupplier + extends ConsumerServiceBaseDescriptorSupplier { + ConsumerServiceFileDescriptorSupplier() {} + } + + private static final class ConsumerServiceMethodDescriptorSupplier + extends ConsumerServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + ConsumerServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (ConsumerServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new ConsumerServiceFileDescriptorSupplier()) + .addMethod(getSubscribeMethod()) + .addMethod(getSubscribeStreamMethod()) + .addMethod(getUnsubscribeMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java new file mode 100644 index 0000000000..c36fa52ee7 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java @@ -0,0 +1,1459 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +/** + * Protobuf type {@code eventmesh.common.protocol.grpc.EventMeshMessage} + */ +public final class EventMeshMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.EventMeshMessage) + EventMeshMessageOrBuilder { +private static final long serialVersionUID = 0L; + // Use EventMeshMessage.newBuilder() to construct. + private EventMeshMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private EventMeshMessage() { + producerGroup_ = ""; + topic_ = ""; + content_ = ""; + ttl_ = ""; + uniqueId_ = ""; + seqNum_ = ""; + tag_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private EventMeshMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + RequestHeader.Builder subBuilder = null; + if (header_ != null) { + subBuilder = header_.toBuilder(); + } + header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(header_); + header_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + producerGroup_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + content_ = s; + break; + } + case 42: { + String s = input.readStringRequireUtf8(); + + ttl_ = s; + break; + } + case 50: { + String s = input.readStringRequireUtf8(); + + uniqueId_ = s; + break; + } + case 58: { + String s = input.readStringRequireUtf8(); + + seqNum_ = s; + break; + } + case 66: { + String s = input.readStringRequireUtf8(); + + tag_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + EventMeshMessage.class, Builder.class); + } + + public static final int HEADER_FIELD_NUMBER = 1; + private RequestHeader header_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + return getHeader(); + } + + public static final int PRODUCERGROUP_FIELD_NUMBER = 2; + private volatile Object producerGroup_; + /** + * string producerGroup = 2; + */ + public String getProducerGroup() { + Object ref = producerGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + producerGroup_ = s; + return s; + } + } + /** + * string producerGroup = 2; + */ + public com.google.protobuf.ByteString + getProducerGroupBytes() { + Object ref = producerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + producerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TOPIC_FIELD_NUMBER = 3; + private volatile Object topic_; + /** + * string topic = 3; + */ + public String getTopic() { + Object ref = topic_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + /** + * string topic = 3; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CONTENT_FIELD_NUMBER = 4; + private volatile Object content_; + /** + * string content = 4; + */ + public String getContent() { + Object ref = content_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + content_ = s; + return s; + } + } + /** + * string content = 4; + */ + public com.google.protobuf.ByteString + getContentBytes() { + Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TTL_FIELD_NUMBER = 5; + private volatile Object ttl_; + /** + * string ttl = 5; + */ + public String getTtl() { + Object ref = ttl_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ttl_ = s; + return s; + } + } + /** + * string ttl = 5; + */ + public com.google.protobuf.ByteString + getTtlBytes() { + Object ref = ttl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ttl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int UNIQUEID_FIELD_NUMBER = 6; + private volatile Object uniqueId_; + /** + * string uniqueId = 6; + */ + public String getUniqueId() { + Object ref = uniqueId_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + uniqueId_ = s; + return s; + } + } + /** + * string uniqueId = 6; + */ + public com.google.protobuf.ByteString + getUniqueIdBytes() { + Object ref = uniqueId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + uniqueId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SEQNUM_FIELD_NUMBER = 7; + private volatile Object seqNum_; + /** + * string seqNum = 7; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } + } + /** + * string seqNum = 7; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TAG_FIELD_NUMBER = 8; + private volatile Object tag_; + /** + * string tag = 8; + */ + public String getTag() { + Object ref = tag_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + tag_ = s; + return s; + } + } + /** + * string tag = 8; + */ + public com.google.protobuf.ByteString + getTagBytes() { + Object ref = tag_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + tag_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (header_ != null) { + output.writeMessage(1, getHeader()); + } + if (!getProducerGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, producerGroup_); + } + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, topic_); + } + if (!getContentBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, content_); + } + if (!getTtlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, ttl_); + } + if (!getUniqueIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, uniqueId_); + } + if (!getSeqNumBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, seqNum_); + } + if (!getTagBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, tag_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (header_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getHeader()); + } + if (!getProducerGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, producerGroup_); + } + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, topic_); + } + if (!getContentBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, content_); + } + if (!getTtlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, ttl_); + } + if (!getUniqueIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, uniqueId_); + } + if (!getSeqNumBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, seqNum_); + } + if (!getTagBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, tag_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof EventMeshMessage)) { + return super.equals(obj); + } + EventMeshMessage other = (EventMeshMessage) obj; + + boolean result = true; + result = result && (hasHeader() == other.hasHeader()); + if (hasHeader()) { + result = result && getHeader() + .equals(other.getHeader()); + } + result = result && getProducerGroup() + .equals(other.getProducerGroup()); + result = result && getTopic() + .equals(other.getTopic()); + result = result && getContent() + .equals(other.getContent()); + result = result && getTtl() + .equals(other.getTtl()); + result = result && getUniqueId() + .equals(other.getUniqueId()); + result = result && getSeqNum() + .equals(other.getSeqNum()); + result = result && getTag() + .equals(other.getTag()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasHeader()) { + hash = (37 * hash) + HEADER_FIELD_NUMBER; + hash = (53 * hash) + getHeader().hashCode(); + } + hash = (37 * hash) + PRODUCERGROUP_FIELD_NUMBER; + hash = (53 * hash) + getProducerGroup().hashCode(); + hash = (37 * hash) + TOPIC_FIELD_NUMBER; + hash = (53 * hash) + getTopic().hashCode(); + hash = (37 * hash) + CONTENT_FIELD_NUMBER; + hash = (53 * hash) + getContent().hashCode(); + hash = (37 * hash) + TTL_FIELD_NUMBER; + hash = (53 * hash) + getTtl().hashCode(); + hash = (37 * hash) + UNIQUEID_FIELD_NUMBER; + hash = (53 * hash) + getUniqueId().hashCode(); + hash = (37 * hash) + SEQNUM_FIELD_NUMBER; + hash = (53 * hash) + getSeqNum().hashCode(); + hash = (37 * hash) + TAG_FIELD_NUMBER; + hash = (53 * hash) + getTag().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static EventMeshMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static EventMeshMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static EventMeshMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static EventMeshMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static EventMeshMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static EventMeshMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static EventMeshMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static EventMeshMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static EventMeshMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static EventMeshMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static EventMeshMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static EventMeshMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(EventMeshMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.EventMeshMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.EventMeshMessage) + EventMeshMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + EventMeshMessage.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (headerBuilder_ == null) { + header_ = null; + } else { + header_ = null; + headerBuilder_ = null; + } + producerGroup_ = ""; + + topic_ = ""; + + content_ = ""; + + ttl_ = ""; + + uniqueId_ = ""; + + seqNum_ = ""; + + tag_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor; + } + + public EventMeshMessage getDefaultInstanceForType() { + return EventMeshMessage.getDefaultInstance(); + } + + public EventMeshMessage build() { + EventMeshMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public EventMeshMessage buildPartial() { + EventMeshMessage result = new EventMeshMessage(this); + if (headerBuilder_ == null) { + result.header_ = header_; + } else { + result.header_ = headerBuilder_.build(); + } + result.producerGroup_ = producerGroup_; + result.topic_ = topic_; + result.content_ = content_; + result.ttl_ = ttl_; + result.uniqueId_ = uniqueId_; + result.seqNum_ = seqNum_; + result.tag_ = tag_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof EventMeshMessage) { + return mergeFrom((EventMeshMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(EventMeshMessage other) { + if (other == EventMeshMessage.getDefaultInstance()) return this; + if (other.hasHeader()) { + mergeHeader(other.getHeader()); + } + if (!other.getProducerGroup().isEmpty()) { + producerGroup_ = other.producerGroup_; + onChanged(); + } + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (!other.getContent().isEmpty()) { + content_ = other.content_; + onChanged(); + } + if (!other.getTtl().isEmpty()) { + ttl_ = other.ttl_; + onChanged(); + } + if (!other.getUniqueId().isEmpty()) { + uniqueId_ = other.uniqueId_; + onChanged(); + } + if (!other.getSeqNum().isEmpty()) { + seqNum_ = other.seqNum_; + onChanged(); + } + if (!other.getTag().isEmpty()) { + tag_ = other.tag_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + EventMeshMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (EventMeshMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private RequestHeader header_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return headerBuilder_ != null || header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + if (headerBuilder_ == null) { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } else { + return headerBuilder_.getMessage(); + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + header_ = value; + onChanged(); + } else { + headerBuilder_.setMessage(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader( + RequestHeader.Builder builderForValue) { + if (headerBuilder_ == null) { + header_ = builderForValue.build(); + onChanged(); + } else { + headerBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder mergeHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (header_ != null) { + header_ = + RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); + } else { + header_ = value; + } + onChanged(); + } else { + headerBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder clearHeader() { + if (headerBuilder_ == null) { + header_ = null; + onChanged(); + } else { + header_ = null; + headerBuilder_ = null; + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader.Builder getHeaderBuilder() { + + onChanged(); + return getHeaderFieldBuilder().getBuilder(); + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + if (headerBuilder_ != null) { + return headerBuilder_.getMessageOrBuilder(); + } else { + return header_ == null ? + RequestHeader.getDefaultInstance() : header_; + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> + getHeaderFieldBuilder() { + if (headerBuilder_ == null) { + headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( + getHeader(), + getParentForChildren(), + isClean()); + header_ = null; + } + return headerBuilder_; + } + + private Object producerGroup_ = ""; + /** + * string producerGroup = 2; + */ + public String getProducerGroup() { + Object ref = producerGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + producerGroup_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string producerGroup = 2; + */ + public com.google.protobuf.ByteString + getProducerGroupBytes() { + Object ref = producerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + producerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string producerGroup = 2; + */ + public Builder setProducerGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + producerGroup_ = value; + onChanged(); + return this; + } + /** + * string producerGroup = 2; + */ + public Builder clearProducerGroup() { + + producerGroup_ = getDefaultInstance().getProducerGroup(); + onChanged(); + return this; + } + /** + * string producerGroup = 2; + */ + public Builder setProducerGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + producerGroup_ = value; + onChanged(); + return this; + } + + private Object topic_ = ""; + /** + * string topic = 3; + */ + public String getTopic() { + Object ref = topic_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string topic = 3; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string topic = 3; + */ + public Builder setTopic( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * string topic = 3; + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * string topic = 3; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private Object content_ = ""; + /** + * string content = 4; + */ + public String getContent() { + Object ref = content_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + content_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string content = 4; + */ + public com.google.protobuf.ByteString + getContentBytes() { + Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string content = 4; + */ + public Builder setContent( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + content_ = value; + onChanged(); + return this; + } + /** + * string content = 4; + */ + public Builder clearContent() { + + content_ = getDefaultInstance().getContent(); + onChanged(); + return this; + } + /** + * string content = 4; + */ + public Builder setContentBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + content_ = value; + onChanged(); + return this; + } + + private Object ttl_ = ""; + /** + * string ttl = 5; + */ + public String getTtl() { + Object ref = ttl_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ttl_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string ttl = 5; + */ + public com.google.protobuf.ByteString + getTtlBytes() { + Object ref = ttl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ttl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string ttl = 5; + */ + public Builder setTtl( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + ttl_ = value; + onChanged(); + return this; + } + /** + * string ttl = 5; + */ + public Builder clearTtl() { + + ttl_ = getDefaultInstance().getTtl(); + onChanged(); + return this; + } + /** + * string ttl = 5; + */ + public Builder setTtlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + ttl_ = value; + onChanged(); + return this; + } + + private Object uniqueId_ = ""; + /** + * string uniqueId = 6; + */ + public String getUniqueId() { + Object ref = uniqueId_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + uniqueId_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string uniqueId = 6; + */ + public com.google.protobuf.ByteString + getUniqueIdBytes() { + Object ref = uniqueId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + uniqueId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string uniqueId = 6; + */ + public Builder setUniqueId( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + uniqueId_ = value; + onChanged(); + return this; + } + /** + * string uniqueId = 6; + */ + public Builder clearUniqueId() { + + uniqueId_ = getDefaultInstance().getUniqueId(); + onChanged(); + return this; + } + /** + * string uniqueId = 6; + */ + public Builder setUniqueIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + uniqueId_ = value; + onChanged(); + return this; + } + + private Object seqNum_ = ""; + /** + * string seqNum = 7; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string seqNum = 7; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string seqNum = 7; + */ + public Builder setSeqNum( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + seqNum_ = value; + onChanged(); + return this; + } + /** + * string seqNum = 7; + */ + public Builder clearSeqNum() { + + seqNum_ = getDefaultInstance().getSeqNum(); + onChanged(); + return this; + } + /** + * string seqNum = 7; + */ + public Builder setSeqNumBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + seqNum_ = value; + onChanged(); + return this; + } + + private Object tag_ = ""; + /** + * string tag = 8; + */ + public String getTag() { + Object ref = tag_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + tag_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string tag = 8; + */ + public com.google.protobuf.ByteString + getTagBytes() { + Object ref = tag_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + tag_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string tag = 8; + */ + public Builder setTag( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + tag_ = value; + onChanged(); + return this; + } + /** + * string tag = 8; + */ + public Builder clearTag() { + + tag_ = getDefaultInstance().getTag(); + onChanged(); + return this; + } + /** + * string tag = 8; + */ + public Builder setTagBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + tag_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.EventMeshMessage) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.EventMeshMessage) + private static final EventMeshMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new EventMeshMessage(); + } + + public static EventMeshMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public EventMeshMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new EventMeshMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public EventMeshMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java new file mode 100644 index 0000000000..505bbdd1cc --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java @@ -0,0 +1,92 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public interface EventMeshMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.EventMeshMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + boolean hasHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeader getHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeaderOrBuilder getHeaderOrBuilder(); + + /** + * string producerGroup = 2; + */ + String getProducerGroup(); + /** + * string producerGroup = 2; + */ + com.google.protobuf.ByteString + getProducerGroupBytes(); + + /** + * string topic = 3; + */ + String getTopic(); + /** + * string topic = 3; + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * string content = 4; + */ + String getContent(); + /** + * string content = 4; + */ + com.google.protobuf.ByteString + getContentBytes(); + + /** + * string ttl = 5; + */ + String getTtl(); + /** + * string ttl = 5; + */ + com.google.protobuf.ByteString + getTtlBytes(); + + /** + * string uniqueId = 6; + */ + String getUniqueId(); + /** + * string uniqueId = 6; + */ + com.google.protobuf.ByteString + getUniqueIdBytes(); + + /** + * string seqNum = 7; + */ + String getSeqNum(); + /** + * string seqNum = 7; + */ + com.google.protobuf.ByteString + getSeqNumBytes(); + + /** + * string tag = 8; + */ + String getTag(); + /** + * string tag = 8; + */ + com.google.protobuf.ByteString + getTagBytes(); +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java new file mode 100644 index 0000000000..2506c9bfbd --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java @@ -0,0 +1,177 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public final class EventmeshGrpc { + private EventmeshGrpc() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_Response_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + String[] descriptorData = { + "\n\026eventmesh-client.proto\022\036eventmesh.comm" + + "on.protocol.grpc\"\332\001\n\rRequestHeader\022\013\n\003en" + + "v\030\001 \001(\t\022\016\n\006region\030\002 \001(\t\022\013\n\003idc\030\003 \001(\t\022\n\n\002" + + "ip\030\004 \001(\t\022\013\n\003pid\030\005 \001(\t\022\013\n\003sys\030\006 \001(\t\022\020\n\010us" + + "ername\030\007 \001(\t\022\020\n\010password\030\010 \001(\t\022\020\n\010langua" + + "ge\030\t \001(\t\022\024\n\014protocolType\030\n \001(\t\022\027\n\017protoc" + + "olVersion\030\013 \001(\t\022\024\n\014protocolDesc\030\014 \001(\t\"\304\001" + + "\n\020EventMeshMessage\022=\n\006header\030\001 \001(\0132-.eve" + + "ntmesh.common.protocol.grpc.RequestHeade" + + "r\022\025\n\rproducerGroup\030\002 \001(\t\022\r\n\005topic\030\003 \001(\t\022" + + "\017\n\007content\030\004 \001(\t\022\013\n\003ttl\030\005 \001(\t\022\020\n\010uniqueI" + + "d\030\006 \001(\t\022\016\n\006seqNum\030\007 \001(\t\022\013\n\003tag\030\010 \001(\t\"O\n\010" + + "Response\022\020\n\010respCode\030\001 \001(\t\022\017\n\007respMsg\030\002 " + + "\001(\t\022\020\n\010respTime\030\003 \001(\t\022\016\n\006seqNum\030\004 \001(\t\"\212\004" + + "\n\014Subscription\022=\n\006header\030\001 \001(\0132-.eventme" + + "sh.common.protocol.grpc.RequestHeader\022\025\n" + + "\rconsumerGroup\030\002 \001(\t\022X\n\021subscriptionItem" + + "s\030\003 \003(\0132=.eventmesh.common.protocol.grpc" + + ".Subscription.SubscriptionItem\022\013\n\003url\030\004 " + + "\001(\t\032\274\002\n\020SubscriptionItem\022\r\n\005topic\030\001 \001(\t\022" + + "\\\n\004mode\030\002 \001(\0162N.eventmesh.common.protoco" + + "l.grpc.Subscription.SubscriptionItem.Sub" + + "scriptionMode\022\\\n\004type\030\003 \001(\0162N.eventmesh." + + "common.protocol.grpc.Subscription.Subscr" + + "iptionItem.SubscriptionType\"4\n\020Subscript" + + "ionMode\022\016\n\nCLUSTERING\020\000\022\020\n\014BROADCASTING\020" + + "\001\"\'\n\020SubscriptionType\022\t\n\005ASYNC\020\000\022\010\n\004SYNC" + + "\020\001\"\340\002\n\tHeartbeat\022=\n\006header\030\001 \001(\0132-.event" + + "mesh.common.protocol.grpc.RequestHeader\022" + + "H\n\nclientType\030\002 \001(\01624.eventmesh.common.p" + + "rotocol.grpc.Heartbeat.ClientType\022\025\n\rpro" + + "ducerGroup\030\003 \001(\t\022\025\n\rconsumerGroup\030\004 \001(\t\022" + + "O\n\016heartbeatItems\030\005 \003(\01327.eventmesh.comm" + + "on.protocol.grpc.Heartbeat.HeartbeatItem" + + "\032+\n\rHeartbeatItem\022\r\n\005topic\030\001 \001(\t\022\013\n\003url\030" + + "\002 \001(\t\"\036\n\nClientType\022\007\n\003PUB\020\000\022\007\n\003SUB\020\0012\316\002" + + "\n\020PublisherService\022e\n\007publish\0220.eventmes" + + "h.common.protocol.grpc.EventMeshMessage\032" + + "(.eventmesh.common.protocol.grpc.Respons" + + "e\022j\n\014requestReply\0220.eventmesh.common.pro" + + "tocol.grpc.EventMeshMessage\032(.eventmesh." + + "common.protocol.grpc.Response\022g\n\tbroadca" + + "st\0220.eventmesh.common.protocol.grpc.Even" + + "tMeshMessage\032(.eventmesh.common.protocol" + + ".grpc.Response2\322\002\n\017ConsumerService\022c\n\tsu" + + "bscribe\022,.eventmesh.common.protocol.grpc" + + ".Subscription\032(.eventmesh.common.protoco" + + "l.grpc.Response\022s\n\017subscribeStream\022,.eve" + + "ntmesh.common.protocol.grpc.Subscription" + + "\0320.eventmesh.common.protocol.grpc.EventM" + + "eshMessage0\001\022e\n\013unsubscribe\022,.eventmesh." + + "common.protocol.grpc.Subscription\032(.even" + + "tmesh.common.protocol.grpc.Response2t\n\020H" + + "eartbeatService\022`\n\theartbeat\022).eventmesh" + + ".common.protocol.grpc.Heartbeat\032(.eventm" + + "esh.common.protocol.grpc.ResponseBC\n0org" + + ".apache.eventmesh.common.protocol.grpc.p" + + "rotosB\rEventmeshGrpcP\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor, + new String[] { "Env", "Region", "Idc", "Ip", "Pid", "Sys", "Username", "Password", "Language", "ProtocolType", "ProtocolVersion", "ProtocolDesc", }); + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor, + new String[] { "Header", "ProducerGroup", "Topic", "Content", "Ttl", "UniqueId", "SeqNum", "Tag", }); + internal_static_eventmesh_common_protocol_grpc_Response_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_Response_descriptor, + new String[] { "RespCode", "RespMsg", "RespTime", "SeqNum", }); + internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor, + new String[] { "Header", "ConsumerGroup", "SubscriptionItems", "Url", }); + internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor = + internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor.getNestedTypes().get(0); + internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor, + new String[] { "Topic", "Mode", "Type", }); + internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor, + new String[] { "Header", "ClientType", "ProducerGroup", "ConsumerGroup", "HeartbeatItems", }); + internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor = + internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor.getNestedTypes().get(0); + internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor, + new String[] { "Topic", "Url", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java new file mode 100644 index 0000000000..64e95fd3d8 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java @@ -0,0 +1,2015 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +/** + * Protobuf type {@code eventmesh.common.protocol.grpc.Heartbeat} + */ +public final class Heartbeat extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Heartbeat) + HeartbeatOrBuilder { +private static final long serialVersionUID = 0L; + // Use Heartbeat.newBuilder() to construct. + private Heartbeat(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Heartbeat() { + clientType_ = 0; + producerGroup_ = ""; + consumerGroup_ = ""; + heartbeatItems_ = java.util.Collections.emptyList(); + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Heartbeat( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + RequestHeader.Builder subBuilder = null; + if (header_ != null) { + subBuilder = header_.toBuilder(); + } + header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(header_); + header_ = subBuilder.buildPartial(); + } + + break; + } + case 16: { + int rawValue = input.readEnum(); + + clientType_ = rawValue; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + producerGroup_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + consumerGroup_ = s; + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + heartbeatItems_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + heartbeatItems_.add( + input.readMessage(HeartbeatItem.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + heartbeatItems_ = java.util.Collections.unmodifiableList(heartbeatItems_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Heartbeat.class, Builder.class); + } + + /** + * Protobuf enum {@code eventmesh.common.protocol.grpc.Heartbeat.ClientType} + */ + public enum ClientType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * PUB = 0; + */ + PUB(0), + /** + * SUB = 1; + */ + SUB(1), + UNRECOGNIZED(-1), + ; + + /** + * PUB = 0; + */ + public static final int PUB_VALUE = 0; + /** + * SUB = 1; + */ + public static final int SUB_VALUE = 1; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @Deprecated + public static ClientType valueOf(int value) { + return forNumber(value); + } + + public static ClientType forNumber(int value) { + switch (value) { + case 0: return PUB; + case 1: return SUB; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + ClientType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ClientType findValueByNumber(int number) { + return ClientType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return Heartbeat.getDescriptor().getEnumTypes().get(0); + } + + private static final ClientType[] VALUES = values(); + + public static ClientType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ClientType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:eventmesh.common.protocol.grpc.Heartbeat.ClientType) + } + + public interface HeartbeatItemOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem) + com.google.protobuf.MessageOrBuilder { + + /** + * string topic = 1; + */ + String getTopic(); + /** + * string topic = 1; + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * string url = 2; + */ + String getUrl(); + /** + * string url = 2; + */ + com.google.protobuf.ByteString + getUrlBytes(); + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem} + */ + public static final class HeartbeatItem extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem) + HeartbeatItemOrBuilder { + private static final long serialVersionUID = 0L; + // Use HeartbeatItem.newBuilder() to construct. + private HeartbeatItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private HeartbeatItem() { + topic_ = ""; + url_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private HeartbeatItem( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + url_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + HeartbeatItem.class, Builder.class); + } + + public static final int TOPIC_FIELD_NUMBER = 1; + private volatile Object topic_; + /** + * string topic = 1; + */ + public String getTopic() { + Object ref = topic_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int URL_FIELD_NUMBER = 2; + private volatile Object url_; + /** + * string url = 2; + */ + public String getUrl() { + Object ref = url_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } + } + /** + * string url = 2; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); + } + if (!getUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, url_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); + } + if (!getUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, url_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof HeartbeatItem)) { + return super.equals(obj); + } + HeartbeatItem other = (HeartbeatItem) obj; + + boolean result = true; + result = result && getTopic() + .equals(other.getTopic()); + result = result && getUrl() + .equals(other.getUrl()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TOPIC_FIELD_NUMBER; + hash = (53 * hash) + getTopic().hashCode(); + hash = (37 * hash) + URL_FIELD_NUMBER; + hash = (53 * hash) + getUrl().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static HeartbeatItem parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static HeartbeatItem parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static HeartbeatItem parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static HeartbeatItem parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static HeartbeatItem parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static HeartbeatItem parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static HeartbeatItem parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static HeartbeatItem parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static HeartbeatItem parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static HeartbeatItem parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static HeartbeatItem parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static HeartbeatItem parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(HeartbeatItem prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem) + HeartbeatItemOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + HeartbeatItem.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.HeartbeatItem.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + topic_ = ""; + + url_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor; + } + + public HeartbeatItem getDefaultInstanceForType() { + return HeartbeatItem.getDefaultInstance(); + } + + public HeartbeatItem build() { + HeartbeatItem result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public HeartbeatItem buildPartial() { + HeartbeatItem result = new HeartbeatItem(this); + result.topic_ = topic_; + result.url_ = url_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof HeartbeatItem) { + return mergeFrom((HeartbeatItem)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(HeartbeatItem other) { + if (other == HeartbeatItem.getDefaultInstance()) return this; + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (!other.getUrl().isEmpty()) { + url_ = other.url_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + HeartbeatItem parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (HeartbeatItem) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object topic_ = ""; + /** + * string topic = 1; + */ + public String getTopic() { + Object ref = topic_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string topic = 1; + */ + public Builder setTopic( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * string topic = 1; + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * string topic = 1; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private Object url_ = ""; + /** + * string url = 2; + */ + public String getUrl() { + Object ref = url_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string url = 2; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string url = 2; + */ + public Builder setUrl( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + /** + * string url = 2; + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + /** + * string url = 2; + */ + public Builder setUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + url_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem) + private static final HeartbeatItem DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new HeartbeatItem(); + } + + public static HeartbeatItem getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HeartbeatItem parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new HeartbeatItem(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public HeartbeatItem getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int HEADER_FIELD_NUMBER = 1; + private RequestHeader header_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + return getHeader(); + } + + public static final int CLIENTTYPE_FIELD_NUMBER = 2; + private int clientType_; + /** + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; + */ + public int getClientTypeValue() { + return clientType_; + } + /** + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; + */ + public ClientType getClientType() { + ClientType result = ClientType.valueOf(clientType_); + return result == null ? ClientType.UNRECOGNIZED : result; + } + + public static final int PRODUCERGROUP_FIELD_NUMBER = 3; + private volatile Object producerGroup_; + /** + * string producerGroup = 3; + */ + public String getProducerGroup() { + Object ref = producerGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + producerGroup_ = s; + return s; + } + } + /** + * string producerGroup = 3; + */ + public com.google.protobuf.ByteString + getProducerGroupBytes() { + Object ref = producerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + producerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CONSUMERGROUP_FIELD_NUMBER = 4; + private volatile Object consumerGroup_; + /** + * string consumerGroup = 4; + */ + public String getConsumerGroup() { + Object ref = consumerGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + consumerGroup_ = s; + return s; + } + } + /** + * string consumerGroup = 4; + */ + public com.google.protobuf.ByteString + getConsumerGroupBytes() { + Object ref = consumerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + consumerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int HEARTBEATITEMS_FIELD_NUMBER = 5; + private java.util.List heartbeatItems_; + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List getHeartbeatItemsList() { + return heartbeatItems_; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List + getHeartbeatItemsOrBuilderList() { + return heartbeatItems_; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public int getHeartbeatItemsCount() { + return heartbeatItems_.size(); + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem getHeartbeatItems(int index) { + return heartbeatItems_.get(index); + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder( + int index) { + return heartbeatItems_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (header_ != null) { + output.writeMessage(1, getHeader()); + } + if (clientType_ != ClientType.PUB.getNumber()) { + output.writeEnum(2, clientType_); + } + if (!getProducerGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, producerGroup_); + } + if (!getConsumerGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, consumerGroup_); + } + for (int i = 0; i < heartbeatItems_.size(); i++) { + output.writeMessage(5, heartbeatItems_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (header_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getHeader()); + } + if (clientType_ != ClientType.PUB.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, clientType_); + } + if (!getProducerGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, producerGroup_); + } + if (!getConsumerGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, consumerGroup_); + } + for (int i = 0; i < heartbeatItems_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, heartbeatItems_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Heartbeat)) { + return super.equals(obj); + } + Heartbeat other = (Heartbeat) obj; + + boolean result = true; + result = result && (hasHeader() == other.hasHeader()); + if (hasHeader()) { + result = result && getHeader() + .equals(other.getHeader()); + } + result = result && clientType_ == other.clientType_; + result = result && getProducerGroup() + .equals(other.getProducerGroup()); + result = result && getConsumerGroup() + .equals(other.getConsumerGroup()); + result = result && getHeartbeatItemsList() + .equals(other.getHeartbeatItemsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasHeader()) { + hash = (37 * hash) + HEADER_FIELD_NUMBER; + hash = (53 * hash) + getHeader().hashCode(); + } + hash = (37 * hash) + CLIENTTYPE_FIELD_NUMBER; + hash = (53 * hash) + clientType_; + hash = (37 * hash) + PRODUCERGROUP_FIELD_NUMBER; + hash = (53 * hash) + getProducerGroup().hashCode(); + hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER; + hash = (53 * hash) + getConsumerGroup().hashCode(); + if (getHeartbeatItemsCount() > 0) { + hash = (37 * hash) + HEARTBEATITEMS_FIELD_NUMBER; + hash = (53 * hash) + getHeartbeatItemsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static Heartbeat parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Heartbeat parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Heartbeat parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Heartbeat parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Heartbeat parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Heartbeat parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Heartbeat parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Heartbeat parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static Heartbeat parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static Heartbeat parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static Heartbeat parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Heartbeat parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(Heartbeat prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Heartbeat} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Heartbeat) + HeartbeatOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Heartbeat.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getHeartbeatItemsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (headerBuilder_ == null) { + header_ = null; + } else { + header_ = null; + headerBuilder_ = null; + } + clientType_ = 0; + + producerGroup_ = ""; + + consumerGroup_ = ""; + + if (heartbeatItemsBuilder_ == null) { + heartbeatItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + } else { + heartbeatItemsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor; + } + + public Heartbeat getDefaultInstanceForType() { + return Heartbeat.getDefaultInstance(); + } + + public Heartbeat build() { + Heartbeat result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Heartbeat buildPartial() { + Heartbeat result = new Heartbeat(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (headerBuilder_ == null) { + result.header_ = header_; + } else { + result.header_ = headerBuilder_.build(); + } + result.clientType_ = clientType_; + result.producerGroup_ = producerGroup_; + result.consumerGroup_ = consumerGroup_; + if (heartbeatItemsBuilder_ == null) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { + heartbeatItems_ = java.util.Collections.unmodifiableList(heartbeatItems_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.heartbeatItems_ = heartbeatItems_; + } else { + result.heartbeatItems_ = heartbeatItemsBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Heartbeat) { + return mergeFrom((Heartbeat)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Heartbeat other) { + if (other == Heartbeat.getDefaultInstance()) return this; + if (other.hasHeader()) { + mergeHeader(other.getHeader()); + } + if (other.clientType_ != 0) { + setClientTypeValue(other.getClientTypeValue()); + } + if (!other.getProducerGroup().isEmpty()) { + producerGroup_ = other.producerGroup_; + onChanged(); + } + if (!other.getConsumerGroup().isEmpty()) { + consumerGroup_ = other.consumerGroup_; + onChanged(); + } + if (heartbeatItemsBuilder_ == null) { + if (!other.heartbeatItems_.isEmpty()) { + if (heartbeatItems_.isEmpty()) { + heartbeatItems_ = other.heartbeatItems_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.addAll(other.heartbeatItems_); + } + onChanged(); + } + } else { + if (!other.heartbeatItems_.isEmpty()) { + if (heartbeatItemsBuilder_.isEmpty()) { + heartbeatItemsBuilder_.dispose(); + heartbeatItemsBuilder_ = null; + heartbeatItems_ = other.heartbeatItems_; + bitField0_ = (bitField0_ & ~0x00000010); + heartbeatItemsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getHeartbeatItemsFieldBuilder() : null; + } else { + heartbeatItemsBuilder_.addAllMessages(other.heartbeatItems_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Heartbeat parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Heartbeat) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private RequestHeader header_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return headerBuilder_ != null || header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + if (headerBuilder_ == null) { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } else { + return headerBuilder_.getMessage(); + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + header_ = value; + onChanged(); + } else { + headerBuilder_.setMessage(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader( + RequestHeader.Builder builderForValue) { + if (headerBuilder_ == null) { + header_ = builderForValue.build(); + onChanged(); + } else { + headerBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder mergeHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (header_ != null) { + header_ = + RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); + } else { + header_ = value; + } + onChanged(); + } else { + headerBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder clearHeader() { + if (headerBuilder_ == null) { + header_ = null; + onChanged(); + } else { + header_ = null; + headerBuilder_ = null; + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader.Builder getHeaderBuilder() { + + onChanged(); + return getHeaderFieldBuilder().getBuilder(); + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + if (headerBuilder_ != null) { + return headerBuilder_.getMessageOrBuilder(); + } else { + return header_ == null ? + RequestHeader.getDefaultInstance() : header_; + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> + getHeaderFieldBuilder() { + if (headerBuilder_ == null) { + headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( + getHeader(), + getParentForChildren(), + isClean()); + header_ = null; + } + return headerBuilder_; + } + + private int clientType_ = 0; + /** + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; + */ + public int getClientTypeValue() { + return clientType_; + } + /** + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; + */ + public Builder setClientTypeValue(int value) { + clientType_ = value; + onChanged(); + return this; + } + /** + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; + */ + public ClientType getClientType() { + ClientType result = ClientType.valueOf(clientType_); + return result == null ? ClientType.UNRECOGNIZED : result; + } + /** + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; + */ + public Builder setClientType(ClientType value) { + if (value == null) { + throw new NullPointerException(); + } + + clientType_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; + */ + public Builder clearClientType() { + + clientType_ = 0; + onChanged(); + return this; + } + + private Object producerGroup_ = ""; + /** + * string producerGroup = 3; + */ + public String getProducerGroup() { + Object ref = producerGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + producerGroup_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string producerGroup = 3; + */ + public com.google.protobuf.ByteString + getProducerGroupBytes() { + Object ref = producerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + producerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string producerGroup = 3; + */ + public Builder setProducerGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + producerGroup_ = value; + onChanged(); + return this; + } + /** + * string producerGroup = 3; + */ + public Builder clearProducerGroup() { + + producerGroup_ = getDefaultInstance().getProducerGroup(); + onChanged(); + return this; + } + /** + * string producerGroup = 3; + */ + public Builder setProducerGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + producerGroup_ = value; + onChanged(); + return this; + } + + private Object consumerGroup_ = ""; + /** + * string consumerGroup = 4; + */ + public String getConsumerGroup() { + Object ref = consumerGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + consumerGroup_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string consumerGroup = 4; + */ + public com.google.protobuf.ByteString + getConsumerGroupBytes() { + Object ref = consumerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + consumerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string consumerGroup = 4; + */ + public Builder setConsumerGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + consumerGroup_ = value; + onChanged(); + return this; + } + /** + * string consumerGroup = 4; + */ + public Builder clearConsumerGroup() { + + consumerGroup_ = getDefaultInstance().getConsumerGroup(); + onChanged(); + return this; + } + /** + * string consumerGroup = 4; + */ + public Builder setConsumerGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + consumerGroup_ = value; + onChanged(); + return this; + } + + private java.util.List heartbeatItems_ = + java.util.Collections.emptyList(); + private void ensureHeartbeatItemsIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + heartbeatItems_ = new java.util.ArrayList(heartbeatItems_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder> heartbeatItemsBuilder_; + + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List getHeartbeatItemsList() { + if (heartbeatItemsBuilder_ == null) { + return java.util.Collections.unmodifiableList(heartbeatItems_); + } else { + return heartbeatItemsBuilder_.getMessageList(); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public int getHeartbeatItemsCount() { + if (heartbeatItemsBuilder_ == null) { + return heartbeatItems_.size(); + } else { + return heartbeatItemsBuilder_.getCount(); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem getHeartbeatItems(int index) { + if (heartbeatItemsBuilder_ == null) { + return heartbeatItems_.get(index); + } else { + return heartbeatItemsBuilder_.getMessage(index); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder setHeartbeatItems( + int index, HeartbeatItem value) { + if (heartbeatItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.set(index, value); + onChanged(); + } else { + heartbeatItemsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder setHeartbeatItems( + int index, HeartbeatItem.Builder builderForValue) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.set(index, builderForValue.build()); + onChanged(); + } else { + heartbeatItemsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addHeartbeatItems(HeartbeatItem value) { + if (heartbeatItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.add(value); + onChanged(); + } else { + heartbeatItemsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addHeartbeatItems( + int index, HeartbeatItem value) { + if (heartbeatItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.add(index, value); + onChanged(); + } else { + heartbeatItemsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addHeartbeatItems( + HeartbeatItem.Builder builderForValue) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.add(builderForValue.build()); + onChanged(); + } else { + heartbeatItemsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addHeartbeatItems( + int index, HeartbeatItem.Builder builderForValue) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.add(index, builderForValue.build()); + onChanged(); + } else { + heartbeatItemsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addAllHeartbeatItems( + Iterable values) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, heartbeatItems_); + onChanged(); + } else { + heartbeatItemsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder clearHeartbeatItems() { + if (heartbeatItemsBuilder_ == null) { + heartbeatItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + heartbeatItemsBuilder_.clear(); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder removeHeartbeatItems(int index) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.remove(index); + onChanged(); + } else { + heartbeatItemsBuilder_.remove(index); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem.Builder getHeartbeatItemsBuilder( + int index) { + return getHeartbeatItemsFieldBuilder().getBuilder(index); + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder( + int index) { + if (heartbeatItemsBuilder_ == null) { + return heartbeatItems_.get(index); } else { + return heartbeatItemsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List + getHeartbeatItemsOrBuilderList() { + if (heartbeatItemsBuilder_ != null) { + return heartbeatItemsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(heartbeatItems_); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem.Builder addHeartbeatItemsBuilder() { + return getHeartbeatItemsFieldBuilder().addBuilder( + HeartbeatItem.getDefaultInstance()); + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem.Builder addHeartbeatItemsBuilder( + int index) { + return getHeartbeatItemsFieldBuilder().addBuilder( + index, HeartbeatItem.getDefaultInstance()); + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List + getHeartbeatItemsBuilderList() { + return getHeartbeatItemsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder> + getHeartbeatItemsFieldBuilder() { + if (heartbeatItemsBuilder_ == null) { + heartbeatItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder>( + heartbeatItems_, + ((bitField0_ & 0x00000010) == 0x00000010), + getParentForChildren(), + isClean()); + heartbeatItems_ = null; + } + return heartbeatItemsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Heartbeat) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Heartbeat) + private static final Heartbeat DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new Heartbeat(); + } + + public static Heartbeat getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Heartbeat parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Heartbeat(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Heartbeat getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java new file mode 100644 index 0000000000..7c900099a2 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java @@ -0,0 +1,75 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public interface HeartbeatOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Heartbeat) + com.google.protobuf.MessageOrBuilder { + + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + boolean hasHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeader getHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeaderOrBuilder getHeaderOrBuilder(); + + /** + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; + */ + int getClientTypeValue(); + /** + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; + */ + Heartbeat.ClientType getClientType(); + + /** + * string producerGroup = 3; + */ + String getProducerGroup(); + /** + * string producerGroup = 3; + */ + com.google.protobuf.ByteString + getProducerGroupBytes(); + + /** + * string consumerGroup = 4; + */ + String getConsumerGroup(); + /** + * string consumerGroup = 4; + */ + com.google.protobuf.ByteString + getConsumerGroupBytes(); + + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + java.util.List + getHeartbeatItemsList(); + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + Heartbeat.HeartbeatItem getHeartbeatItems(int index); + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + int getHeartbeatItemsCount(); + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + java.util.List + getHeartbeatItemsOrBuilderList(); + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + Heartbeat.HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder( + int index); +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java new file mode 100644 index 0000000000..5224e01d0a --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java @@ -0,0 +1,280 @@ +package org.apache.eventmesh.common.protocol.grpc.protos; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.15.0)", + comments = "Source: eventmesh-client.proto") +public final class HeartbeatServiceGrpc { + + private HeartbeatServiceGrpc() {} + + public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.HeartbeatService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getHeartbeatMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "heartbeat", + requestType = Heartbeat.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getHeartbeatMethod() { + io.grpc.MethodDescriptor getHeartbeatMethod; + if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { + synchronized (HeartbeatServiceGrpc.class) { + if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { + HeartbeatServiceGrpc.getHeartbeatMethod = getHeartbeatMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.HeartbeatService", "heartbeat")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Heartbeat.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new HeartbeatServiceMethodDescriptorSupplier("heartbeat")) + .build(); + } + } + } + return getHeartbeatMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static HeartbeatServiceStub newStub(io.grpc.Channel channel) { + return new HeartbeatServiceStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static HeartbeatServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new HeartbeatServiceBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static HeartbeatServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + return new HeartbeatServiceFutureStub(channel); + } + + /** + */ + public static abstract class HeartbeatServiceImplBase implements io.grpc.BindableService { + + /** + */ + public void heartbeat(Heartbeat request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getHeartbeatMethod(), responseObserver); + } + + @Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getHeartbeatMethod(), + asyncUnaryCall( + new MethodHandlers< + Heartbeat, + Response>( + this, METHODID_HEARTBEAT))) + .build(); + } + } + + /** + */ + public static final class HeartbeatServiceStub extends io.grpc.stub.AbstractStub { + private HeartbeatServiceStub(io.grpc.Channel channel) { + super(channel); + } + + private HeartbeatServiceStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected HeartbeatServiceStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new HeartbeatServiceStub(channel, callOptions); + } + + /** + */ + public void heartbeat(Heartbeat request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class HeartbeatServiceBlockingStub extends io.grpc.stub.AbstractStub { + private HeartbeatServiceBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private HeartbeatServiceBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected HeartbeatServiceBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new HeartbeatServiceBlockingStub(channel, callOptions); + } + + /** + */ + public Response heartbeat(Heartbeat request) { + return blockingUnaryCall( + getChannel(), getHeartbeatMethod(), getCallOptions(), request); + } + } + + /** + */ + public static final class HeartbeatServiceFutureStub extends io.grpc.stub.AbstractStub { + private HeartbeatServiceFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private HeartbeatServiceFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected HeartbeatServiceFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new HeartbeatServiceFutureStub(channel, callOptions); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture heartbeat( + Heartbeat request) { + return futureUnaryCall( + getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_HEARTBEAT = 0; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final HeartbeatServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(HeartbeatServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @Override + @SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_HEARTBEAT: + serviceImpl.heartbeat((Heartbeat) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @Override + @SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class HeartbeatServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + HeartbeatServiceBaseDescriptorSupplier() {} + + @Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return EventmeshGrpc.getDescriptor(); + } + + @Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("HeartbeatService"); + } + } + + private static final class HeartbeatServiceFileDescriptorSupplier + extends HeartbeatServiceBaseDescriptorSupplier { + HeartbeatServiceFileDescriptorSupplier() {} + } + + private static final class HeartbeatServiceMethodDescriptorSupplier + extends HeartbeatServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + HeartbeatServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (HeartbeatServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new HeartbeatServiceFileDescriptorSupplier()) + .addMethod(getHeartbeatMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java new file mode 100644 index 0000000000..c23bb07cc2 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java @@ -0,0 +1,430 @@ +package org.apache.eventmesh.common.protocol.grpc.protos; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.15.0)", + comments = "Source: eventmesh-client.proto") +public final class PublisherServiceGrpc { + + private PublisherServiceGrpc() {} + + public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.PublisherService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getPublishMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "publish", + requestType = EventMeshMessage.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getPublishMethod() { + io.grpc.MethodDescriptor getPublishMethod; + if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { + synchronized (PublisherServiceGrpc.class) { + if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { + PublisherServiceGrpc.getPublishMethod = getPublishMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.PublisherService", "publish")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + EventMeshMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("publish")) + .build(); + } + } + } + return getPublishMethod; + } + + private static volatile io.grpc.MethodDescriptor getRequestReplyMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "requestReply", + requestType = EventMeshMessage.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getRequestReplyMethod() { + io.grpc.MethodDescriptor getRequestReplyMethod; + if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { + synchronized (PublisherServiceGrpc.class) { + if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { + PublisherServiceGrpc.getRequestReplyMethod = getRequestReplyMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.PublisherService", "requestReply")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + EventMeshMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("requestReply")) + .build(); + } + } + } + return getRequestReplyMethod; + } + + private static volatile io.grpc.MethodDescriptor getBroadcastMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "broadcast", + requestType = EventMeshMessage.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getBroadcastMethod() { + io.grpc.MethodDescriptor getBroadcastMethod; + if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { + synchronized (PublisherServiceGrpc.class) { + if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { + PublisherServiceGrpc.getBroadcastMethod = getBroadcastMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.PublisherService", "broadcast")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + EventMeshMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("broadcast")) + .build(); + } + } + } + return getBroadcastMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static PublisherServiceStub newStub(io.grpc.Channel channel) { + return new PublisherServiceStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static PublisherServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new PublisherServiceBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static PublisherServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + return new PublisherServiceFutureStub(channel); + } + + /** + */ + public static abstract class PublisherServiceImplBase implements io.grpc.BindableService { + + /** + */ + public void publish(EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getPublishMethod(), responseObserver); + } + + /** + */ + public void requestReply(EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getRequestReplyMethod(), responseObserver); + } + + /** + */ + public void broadcast(EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getBroadcastMethod(), responseObserver); + } + + @Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getPublishMethod(), + asyncUnaryCall( + new MethodHandlers< + EventMeshMessage, + Response>( + this, METHODID_PUBLISH))) + .addMethod( + getRequestReplyMethod(), + asyncUnaryCall( + new MethodHandlers< + EventMeshMessage, + Response>( + this, METHODID_REQUEST_REPLY))) + .addMethod( + getBroadcastMethod(), + asyncUnaryCall( + new MethodHandlers< + EventMeshMessage, + Response>( + this, METHODID_BROADCAST))) + .build(); + } + } + + /** + */ + public static final class PublisherServiceStub extends io.grpc.stub.AbstractStub { + private PublisherServiceStub(io.grpc.Channel channel) { + super(channel); + } + + private PublisherServiceStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected PublisherServiceStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PublisherServiceStub(channel, callOptions); + } + + /** + */ + public void publish(EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getPublishMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void requestReply(EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void broadcast(EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getBroadcastMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class PublisherServiceBlockingStub extends io.grpc.stub.AbstractStub { + private PublisherServiceBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private PublisherServiceBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected PublisherServiceBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PublisherServiceBlockingStub(channel, callOptions); + } + + /** + */ + public Response publish(EventMeshMessage request) { + return blockingUnaryCall( + getChannel(), getPublishMethod(), getCallOptions(), request); + } + + /** + */ + public Response requestReply(EventMeshMessage request) { + return blockingUnaryCall( + getChannel(), getRequestReplyMethod(), getCallOptions(), request); + } + + /** + */ + public Response broadcast(EventMeshMessage request) { + return blockingUnaryCall( + getChannel(), getBroadcastMethod(), getCallOptions(), request); + } + } + + /** + */ + public static final class PublisherServiceFutureStub extends io.grpc.stub.AbstractStub { + private PublisherServiceFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private PublisherServiceFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected PublisherServiceFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PublisherServiceFutureStub(channel, callOptions); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture publish( + EventMeshMessage request) { + return futureUnaryCall( + getChannel().newCall(getPublishMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture requestReply( + EventMeshMessage request) { + return futureUnaryCall( + getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture broadcast( + EventMeshMessage request) { + return futureUnaryCall( + getChannel().newCall(getBroadcastMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_PUBLISH = 0; + private static final int METHODID_REQUEST_REPLY = 1; + private static final int METHODID_BROADCAST = 2; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final PublisherServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(PublisherServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @Override + @SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_PUBLISH: + serviceImpl.publish((EventMeshMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_REQUEST_REPLY: + serviceImpl.requestReply((EventMeshMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_BROADCAST: + serviceImpl.broadcast((EventMeshMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @Override + @SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class PublisherServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + PublisherServiceBaseDescriptorSupplier() {} + + @Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return EventmeshGrpc.getDescriptor(); + } + + @Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("PublisherService"); + } + } + + private static final class PublisherServiceFileDescriptorSupplier + extends PublisherServiceBaseDescriptorSupplier { + PublisherServiceFileDescriptorSupplier() {} + } + + private static final class PublisherServiceMethodDescriptorSupplier + extends PublisherServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + PublisherServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (PublisherServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new PublisherServiceFileDescriptorSupplier()) + .addMethod(getPublishMethod()) + .addMethod(getRequestReplyMethod()) + .addMethod(getBroadcastMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java new file mode 100644 index 0000000000..d53cbcbfef --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java @@ -0,0 +1,1913 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +/** + * Protobuf type {@code eventmesh.common.protocol.grpc.RequestHeader} + */ +public final class RequestHeader extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.RequestHeader) + RequestHeaderOrBuilder { +private static final long serialVersionUID = 0L; + // Use RequestHeader.newBuilder() to construct. + private RequestHeader(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private RequestHeader() { + env_ = ""; + region_ = ""; + idc_ = ""; + ip_ = ""; + pid_ = ""; + sys_ = ""; + username_ = ""; + password_ = ""; + language_ = ""; + protocolType_ = ""; + protocolVersion_ = ""; + protocolDesc_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private RequestHeader( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + env_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + region_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + idc_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + ip_ = s; + break; + } + case 42: { + String s = input.readStringRequireUtf8(); + + pid_ = s; + break; + } + case 50: { + String s = input.readStringRequireUtf8(); + + sys_ = s; + break; + } + case 58: { + String s = input.readStringRequireUtf8(); + + username_ = s; + break; + } + case 66: { + String s = input.readStringRequireUtf8(); + + password_ = s; + break; + } + case 74: { + String s = input.readStringRequireUtf8(); + + language_ = s; + break; + } + case 82: { + String s = input.readStringRequireUtf8(); + + protocolType_ = s; + break; + } + case 90: { + String s = input.readStringRequireUtf8(); + + protocolVersion_ = s; + break; + } + case 98: { + String s = input.readStringRequireUtf8(); + + protocolDesc_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RequestHeader.class, Builder.class); + } + + public static final int ENV_FIELD_NUMBER = 1; + private volatile Object env_; + /** + * string env = 1; + */ + public String getEnv() { + Object ref = env_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + env_ = s; + return s; + } + } + /** + * string env = 1; + */ + public com.google.protobuf.ByteString + getEnvBytes() { + Object ref = env_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + env_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int REGION_FIELD_NUMBER = 2; + private volatile Object region_; + /** + * string region = 2; + */ + public String getRegion() { + Object ref = region_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + region_ = s; + return s; + } + } + /** + * string region = 2; + */ + public com.google.protobuf.ByteString + getRegionBytes() { + Object ref = region_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + region_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int IDC_FIELD_NUMBER = 3; + private volatile Object idc_; + /** + * string idc = 3; + */ + public String getIdc() { + Object ref = idc_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + idc_ = s; + return s; + } + } + /** + * string idc = 3; + */ + public com.google.protobuf.ByteString + getIdcBytes() { + Object ref = idc_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + idc_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int IP_FIELD_NUMBER = 4; + private volatile Object ip_; + /** + * string ip = 4; + */ + public String getIp() { + Object ref = ip_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ip_ = s; + return s; + } + } + /** + * string ip = 4; + */ + public com.google.protobuf.ByteString + getIpBytes() { + Object ref = ip_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ip_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PID_FIELD_NUMBER = 5; + private volatile Object pid_; + /** + * string pid = 5; + */ + public String getPid() { + Object ref = pid_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + pid_ = s; + return s; + } + } + /** + * string pid = 5; + */ + public com.google.protobuf.ByteString + getPidBytes() { + Object ref = pid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + pid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SYS_FIELD_NUMBER = 6; + private volatile Object sys_; + /** + * string sys = 6; + */ + public String getSys() { + Object ref = sys_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + sys_ = s; + return s; + } + } + /** + * string sys = 6; + */ + public com.google.protobuf.ByteString + getSysBytes() { + Object ref = sys_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + sys_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int USERNAME_FIELD_NUMBER = 7; + private volatile Object username_; + /** + * string username = 7; + */ + public String getUsername() { + Object ref = username_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + username_ = s; + return s; + } + } + /** + * string username = 7; + */ + public com.google.protobuf.ByteString + getUsernameBytes() { + Object ref = username_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + username_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PASSWORD_FIELD_NUMBER = 8; + private volatile Object password_; + /** + * string password = 8; + */ + public String getPassword() { + Object ref = password_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + password_ = s; + return s; + } + } + /** + * string password = 8; + */ + public com.google.protobuf.ByteString + getPasswordBytes() { + Object ref = password_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + password_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LANGUAGE_FIELD_NUMBER = 9; + private volatile Object language_; + /** + * string language = 9; + */ + public String getLanguage() { + Object ref = language_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + language_ = s; + return s; + } + } + /** + * string language = 9; + */ + public com.google.protobuf.ByteString + getLanguageBytes() { + Object ref = language_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + language_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PROTOCOLTYPE_FIELD_NUMBER = 10; + private volatile Object protocolType_; + /** + * string protocolType = 10; + */ + public String getProtocolType() { + Object ref = protocolType_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + protocolType_ = s; + return s; + } + } + /** + * string protocolType = 10; + */ + public com.google.protobuf.ByteString + getProtocolTypeBytes() { + Object ref = protocolType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + protocolType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PROTOCOLVERSION_FIELD_NUMBER = 11; + private volatile Object protocolVersion_; + /** + * string protocolVersion = 11; + */ + public String getProtocolVersion() { + Object ref = protocolVersion_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + protocolVersion_ = s; + return s; + } + } + /** + * string protocolVersion = 11; + */ + public com.google.protobuf.ByteString + getProtocolVersionBytes() { + Object ref = protocolVersion_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + protocolVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PROTOCOLDESC_FIELD_NUMBER = 12; + private volatile Object protocolDesc_; + /** + * string protocolDesc = 12; + */ + public String getProtocolDesc() { + Object ref = protocolDesc_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + protocolDesc_ = s; + return s; + } + } + /** + * string protocolDesc = 12; + */ + public com.google.protobuf.ByteString + getProtocolDescBytes() { + Object ref = protocolDesc_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + protocolDesc_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getEnvBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, env_); + } + if (!getRegionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, region_); + } + if (!getIdcBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, idc_); + } + if (!getIpBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, ip_); + } + if (!getPidBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, pid_); + } + if (!getSysBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, sys_); + } + if (!getUsernameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, username_); + } + if (!getPasswordBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, password_); + } + if (!getLanguageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, language_); + } + if (!getProtocolTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 10, protocolType_); + } + if (!getProtocolVersionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 11, protocolVersion_); + } + if (!getProtocolDescBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 12, protocolDesc_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getEnvBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, env_); + } + if (!getRegionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, region_); + } + if (!getIdcBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, idc_); + } + if (!getIpBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, ip_); + } + if (!getPidBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, pid_); + } + if (!getSysBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, sys_); + } + if (!getUsernameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, username_); + } + if (!getPasswordBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, password_); + } + if (!getLanguageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, language_); + } + if (!getProtocolTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, protocolType_); + } + if (!getProtocolVersionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, protocolVersion_); + } + if (!getProtocolDescBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(12, protocolDesc_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof RequestHeader)) { + return super.equals(obj); + } + RequestHeader other = (RequestHeader) obj; + + boolean result = true; + result = result && getEnv() + .equals(other.getEnv()); + result = result && getRegion() + .equals(other.getRegion()); + result = result && getIdc() + .equals(other.getIdc()); + result = result && getIp() + .equals(other.getIp()); + result = result && getPid() + .equals(other.getPid()); + result = result && getSys() + .equals(other.getSys()); + result = result && getUsername() + .equals(other.getUsername()); + result = result && getPassword() + .equals(other.getPassword()); + result = result && getLanguage() + .equals(other.getLanguage()); + result = result && getProtocolType() + .equals(other.getProtocolType()); + result = result && getProtocolVersion() + .equals(other.getProtocolVersion()); + result = result && getProtocolDesc() + .equals(other.getProtocolDesc()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ENV_FIELD_NUMBER; + hash = (53 * hash) + getEnv().hashCode(); + hash = (37 * hash) + REGION_FIELD_NUMBER; + hash = (53 * hash) + getRegion().hashCode(); + hash = (37 * hash) + IDC_FIELD_NUMBER; + hash = (53 * hash) + getIdc().hashCode(); + hash = (37 * hash) + IP_FIELD_NUMBER; + hash = (53 * hash) + getIp().hashCode(); + hash = (37 * hash) + PID_FIELD_NUMBER; + hash = (53 * hash) + getPid().hashCode(); + hash = (37 * hash) + SYS_FIELD_NUMBER; + hash = (53 * hash) + getSys().hashCode(); + hash = (37 * hash) + USERNAME_FIELD_NUMBER; + hash = (53 * hash) + getUsername().hashCode(); + hash = (37 * hash) + PASSWORD_FIELD_NUMBER; + hash = (53 * hash) + getPassword().hashCode(); + hash = (37 * hash) + LANGUAGE_FIELD_NUMBER; + hash = (53 * hash) + getLanguage().hashCode(); + hash = (37 * hash) + PROTOCOLTYPE_FIELD_NUMBER; + hash = (53 * hash) + getProtocolType().hashCode(); + hash = (37 * hash) + PROTOCOLVERSION_FIELD_NUMBER; + hash = (53 * hash) + getProtocolVersion().hashCode(); + hash = (37 * hash) + PROTOCOLDESC_FIELD_NUMBER; + hash = (53 * hash) + getProtocolDesc().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static RequestHeader parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RequestHeader parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RequestHeader parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RequestHeader parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RequestHeader parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RequestHeader parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RequestHeader parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static RequestHeader parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static RequestHeader parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static RequestHeader parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static RequestHeader parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static RequestHeader parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(RequestHeader prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.RequestHeader} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.RequestHeader) + RequestHeaderOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RequestHeader.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + env_ = ""; + + region_ = ""; + + idc_ = ""; + + ip_ = ""; + + pid_ = ""; + + sys_ = ""; + + username_ = ""; + + password_ = ""; + + language_ = ""; + + protocolType_ = ""; + + protocolVersion_ = ""; + + protocolDesc_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor; + } + + public RequestHeader getDefaultInstanceForType() { + return RequestHeader.getDefaultInstance(); + } + + public RequestHeader build() { + RequestHeader result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public RequestHeader buildPartial() { + RequestHeader result = new RequestHeader(this); + result.env_ = env_; + result.region_ = region_; + result.idc_ = idc_; + result.ip_ = ip_; + result.pid_ = pid_; + result.sys_ = sys_; + result.username_ = username_; + result.password_ = password_; + result.language_ = language_; + result.protocolType_ = protocolType_; + result.protocolVersion_ = protocolVersion_; + result.protocolDesc_ = protocolDesc_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof RequestHeader) { + return mergeFrom((RequestHeader)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(RequestHeader other) { + if (other == RequestHeader.getDefaultInstance()) return this; + if (!other.getEnv().isEmpty()) { + env_ = other.env_; + onChanged(); + } + if (!other.getRegion().isEmpty()) { + region_ = other.region_; + onChanged(); + } + if (!other.getIdc().isEmpty()) { + idc_ = other.idc_; + onChanged(); + } + if (!other.getIp().isEmpty()) { + ip_ = other.ip_; + onChanged(); + } + if (!other.getPid().isEmpty()) { + pid_ = other.pid_; + onChanged(); + } + if (!other.getSys().isEmpty()) { + sys_ = other.sys_; + onChanged(); + } + if (!other.getUsername().isEmpty()) { + username_ = other.username_; + onChanged(); + } + if (!other.getPassword().isEmpty()) { + password_ = other.password_; + onChanged(); + } + if (!other.getLanguage().isEmpty()) { + language_ = other.language_; + onChanged(); + } + if (!other.getProtocolType().isEmpty()) { + protocolType_ = other.protocolType_; + onChanged(); + } + if (!other.getProtocolVersion().isEmpty()) { + protocolVersion_ = other.protocolVersion_; + onChanged(); + } + if (!other.getProtocolDesc().isEmpty()) { + protocolDesc_ = other.protocolDesc_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + RequestHeader parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (RequestHeader) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object env_ = ""; + /** + * string env = 1; + */ + public String getEnv() { + Object ref = env_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + env_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string env = 1; + */ + public com.google.protobuf.ByteString + getEnvBytes() { + Object ref = env_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + env_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string env = 1; + */ + public Builder setEnv( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + env_ = value; + onChanged(); + return this; + } + /** + * string env = 1; + */ + public Builder clearEnv() { + + env_ = getDefaultInstance().getEnv(); + onChanged(); + return this; + } + /** + * string env = 1; + */ + public Builder setEnvBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + env_ = value; + onChanged(); + return this; + } + + private Object region_ = ""; + /** + * string region = 2; + */ + public String getRegion() { + Object ref = region_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + region_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string region = 2; + */ + public com.google.protobuf.ByteString + getRegionBytes() { + Object ref = region_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + region_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string region = 2; + */ + public Builder setRegion( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + region_ = value; + onChanged(); + return this; + } + /** + * string region = 2; + */ + public Builder clearRegion() { + + region_ = getDefaultInstance().getRegion(); + onChanged(); + return this; + } + /** + * string region = 2; + */ + public Builder setRegionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + region_ = value; + onChanged(); + return this; + } + + private Object idc_ = ""; + /** + * string idc = 3; + */ + public String getIdc() { + Object ref = idc_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + idc_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string idc = 3; + */ + public com.google.protobuf.ByteString + getIdcBytes() { + Object ref = idc_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + idc_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string idc = 3; + */ + public Builder setIdc( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + idc_ = value; + onChanged(); + return this; + } + /** + * string idc = 3; + */ + public Builder clearIdc() { + + idc_ = getDefaultInstance().getIdc(); + onChanged(); + return this; + } + /** + * string idc = 3; + */ + public Builder setIdcBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + idc_ = value; + onChanged(); + return this; + } + + private Object ip_ = ""; + /** + * string ip = 4; + */ + public String getIp() { + Object ref = ip_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ip_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string ip = 4; + */ + public com.google.protobuf.ByteString + getIpBytes() { + Object ref = ip_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ip_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string ip = 4; + */ + public Builder setIp( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + ip_ = value; + onChanged(); + return this; + } + /** + * string ip = 4; + */ + public Builder clearIp() { + + ip_ = getDefaultInstance().getIp(); + onChanged(); + return this; + } + /** + * string ip = 4; + */ + public Builder setIpBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + ip_ = value; + onChanged(); + return this; + } + + private Object pid_ = ""; + /** + * string pid = 5; + */ + public String getPid() { + Object ref = pid_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + pid_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string pid = 5; + */ + public com.google.protobuf.ByteString + getPidBytes() { + Object ref = pid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + pid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string pid = 5; + */ + public Builder setPid( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + pid_ = value; + onChanged(); + return this; + } + /** + * string pid = 5; + */ + public Builder clearPid() { + + pid_ = getDefaultInstance().getPid(); + onChanged(); + return this; + } + /** + * string pid = 5; + */ + public Builder setPidBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + pid_ = value; + onChanged(); + return this; + } + + private Object sys_ = ""; + /** + * string sys = 6; + */ + public String getSys() { + Object ref = sys_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + sys_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string sys = 6; + */ + public com.google.protobuf.ByteString + getSysBytes() { + Object ref = sys_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + sys_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string sys = 6; + */ + public Builder setSys( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + sys_ = value; + onChanged(); + return this; + } + /** + * string sys = 6; + */ + public Builder clearSys() { + + sys_ = getDefaultInstance().getSys(); + onChanged(); + return this; + } + /** + * string sys = 6; + */ + public Builder setSysBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + sys_ = value; + onChanged(); + return this; + } + + private Object username_ = ""; + /** + * string username = 7; + */ + public String getUsername() { + Object ref = username_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + username_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string username = 7; + */ + public com.google.protobuf.ByteString + getUsernameBytes() { + Object ref = username_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + username_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string username = 7; + */ + public Builder setUsername( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + username_ = value; + onChanged(); + return this; + } + /** + * string username = 7; + */ + public Builder clearUsername() { + + username_ = getDefaultInstance().getUsername(); + onChanged(); + return this; + } + /** + * string username = 7; + */ + public Builder setUsernameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + username_ = value; + onChanged(); + return this; + } + + private Object password_ = ""; + /** + * string password = 8; + */ + public String getPassword() { + Object ref = password_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + password_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string password = 8; + */ + public com.google.protobuf.ByteString + getPasswordBytes() { + Object ref = password_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + password_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string password = 8; + */ + public Builder setPassword( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + password_ = value; + onChanged(); + return this; + } + /** + * string password = 8; + */ + public Builder clearPassword() { + + password_ = getDefaultInstance().getPassword(); + onChanged(); + return this; + } + /** + * string password = 8; + */ + public Builder setPasswordBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + password_ = value; + onChanged(); + return this; + } + + private Object language_ = ""; + /** + * string language = 9; + */ + public String getLanguage() { + Object ref = language_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + language_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string language = 9; + */ + public com.google.protobuf.ByteString + getLanguageBytes() { + Object ref = language_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + language_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string language = 9; + */ + public Builder setLanguage( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + language_ = value; + onChanged(); + return this; + } + /** + * string language = 9; + */ + public Builder clearLanguage() { + + language_ = getDefaultInstance().getLanguage(); + onChanged(); + return this; + } + /** + * string language = 9; + */ + public Builder setLanguageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + language_ = value; + onChanged(); + return this; + } + + private Object protocolType_ = ""; + /** + * string protocolType = 10; + */ + public String getProtocolType() { + Object ref = protocolType_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + protocolType_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string protocolType = 10; + */ + public com.google.protobuf.ByteString + getProtocolTypeBytes() { + Object ref = protocolType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + protocolType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string protocolType = 10; + */ + public Builder setProtocolType( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + protocolType_ = value; + onChanged(); + return this; + } + /** + * string protocolType = 10; + */ + public Builder clearProtocolType() { + + protocolType_ = getDefaultInstance().getProtocolType(); + onChanged(); + return this; + } + /** + * string protocolType = 10; + */ + public Builder setProtocolTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + protocolType_ = value; + onChanged(); + return this; + } + + private Object protocolVersion_ = ""; + /** + * string protocolVersion = 11; + */ + public String getProtocolVersion() { + Object ref = protocolVersion_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + protocolVersion_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string protocolVersion = 11; + */ + public com.google.protobuf.ByteString + getProtocolVersionBytes() { + Object ref = protocolVersion_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + protocolVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string protocolVersion = 11; + */ + public Builder setProtocolVersion( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + protocolVersion_ = value; + onChanged(); + return this; + } + /** + * string protocolVersion = 11; + */ + public Builder clearProtocolVersion() { + + protocolVersion_ = getDefaultInstance().getProtocolVersion(); + onChanged(); + return this; + } + /** + * string protocolVersion = 11; + */ + public Builder setProtocolVersionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + protocolVersion_ = value; + onChanged(); + return this; + } + + private Object protocolDesc_ = ""; + /** + * string protocolDesc = 12; + */ + public String getProtocolDesc() { + Object ref = protocolDesc_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + protocolDesc_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string protocolDesc = 12; + */ + public com.google.protobuf.ByteString + getProtocolDescBytes() { + Object ref = protocolDesc_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + protocolDesc_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string protocolDesc = 12; + */ + public Builder setProtocolDesc( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + protocolDesc_ = value; + onChanged(); + return this; + } + /** + * string protocolDesc = 12; + */ + public Builder clearProtocolDesc() { + + protocolDesc_ = getDefaultInstance().getProtocolDesc(); + onChanged(); + return this; + } + /** + * string protocolDesc = 12; + */ + public Builder setProtocolDescBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + protocolDesc_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.RequestHeader) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.RequestHeader) + private static final RequestHeader DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new RequestHeader(); + } + + public static RequestHeader getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public RequestHeader parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new RequestHeader(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public RequestHeader getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java new file mode 100644 index 0000000000..ab28df49f2 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java @@ -0,0 +1,129 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public interface RequestHeaderOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.RequestHeader) + com.google.protobuf.MessageOrBuilder { + + /** + * string env = 1; + */ + String getEnv(); + /** + * string env = 1; + */ + com.google.protobuf.ByteString + getEnvBytes(); + + /** + * string region = 2; + */ + String getRegion(); + /** + * string region = 2; + */ + com.google.protobuf.ByteString + getRegionBytes(); + + /** + * string idc = 3; + */ + String getIdc(); + /** + * string idc = 3; + */ + com.google.protobuf.ByteString + getIdcBytes(); + + /** + * string ip = 4; + */ + String getIp(); + /** + * string ip = 4; + */ + com.google.protobuf.ByteString + getIpBytes(); + + /** + * string pid = 5; + */ + String getPid(); + /** + * string pid = 5; + */ + com.google.protobuf.ByteString + getPidBytes(); + + /** + * string sys = 6; + */ + String getSys(); + /** + * string sys = 6; + */ + com.google.protobuf.ByteString + getSysBytes(); + + /** + * string username = 7; + */ + String getUsername(); + /** + * string username = 7; + */ + com.google.protobuf.ByteString + getUsernameBytes(); + + /** + * string password = 8; + */ + String getPassword(); + /** + * string password = 8; + */ + com.google.protobuf.ByteString + getPasswordBytes(); + + /** + * string language = 9; + */ + String getLanguage(); + /** + * string language = 9; + */ + com.google.protobuf.ByteString + getLanguageBytes(); + + /** + * string protocolType = 10; + */ + String getProtocolType(); + /** + * string protocolType = 10; + */ + com.google.protobuf.ByteString + getProtocolTypeBytes(); + + /** + * string protocolVersion = 11; + */ + String getProtocolVersion(); + /** + * string protocolVersion = 11; + */ + com.google.protobuf.ByteString + getProtocolVersionBytes(); + + /** + * string protocolDesc = 12; + */ + String getProtocolDesc(); + /** + * string protocolDesc = 12; + */ + com.google.protobuf.ByteString + getProtocolDescBytes(); +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java new file mode 100644 index 0000000000..008b0a1210 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java @@ -0,0 +1,897 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +/** + * Protobuf type {@code eventmesh.common.protocol.grpc.Response} + */ +public final class Response extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Response) + ResponseOrBuilder { +private static final long serialVersionUID = 0L; + // Use Response.newBuilder() to construct. + private Response(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Response() { + respCode_ = ""; + respMsg_ = ""; + respTime_ = ""; + seqNum_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Response( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + respCode_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + respMsg_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + respTime_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + seqNum_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Response.class, Builder.class); + } + + public static final int RESPCODE_FIELD_NUMBER = 1; + private volatile Object respCode_; + /** + * string respCode = 1; + */ + public String getRespCode() { + Object ref = respCode_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respCode_ = s; + return s; + } + } + /** + * string respCode = 1; + */ + public com.google.protobuf.ByteString + getRespCodeBytes() { + Object ref = respCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RESPMSG_FIELD_NUMBER = 2; + private volatile Object respMsg_; + /** + * string respMsg = 2; + */ + public String getRespMsg() { + Object ref = respMsg_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respMsg_ = s; + return s; + } + } + /** + * string respMsg = 2; + */ + public com.google.protobuf.ByteString + getRespMsgBytes() { + Object ref = respMsg_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respMsg_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RESPTIME_FIELD_NUMBER = 3; + private volatile Object respTime_; + /** + * string respTime = 3; + */ + public String getRespTime() { + Object ref = respTime_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respTime_ = s; + return s; + } + } + /** + * string respTime = 3; + */ + public com.google.protobuf.ByteString + getRespTimeBytes() { + Object ref = respTime_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respTime_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SEQNUM_FIELD_NUMBER = 4; + private volatile Object seqNum_; + /** + * string seqNum = 4; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } + } + /** + * string seqNum = 4; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getRespCodeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, respCode_); + } + if (!getRespMsgBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, respMsg_); + } + if (!getRespTimeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, respTime_); + } + if (!getSeqNumBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, seqNum_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getRespCodeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, respCode_); + } + if (!getRespMsgBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, respMsg_); + } + if (!getRespTimeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, respTime_); + } + if (!getSeqNumBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, seqNum_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Response)) { + return super.equals(obj); + } + Response other = (Response) obj; + + boolean result = true; + result = result && getRespCode() + .equals(other.getRespCode()); + result = result && getRespMsg() + .equals(other.getRespMsg()); + result = result && getRespTime() + .equals(other.getRespTime()); + result = result && getSeqNum() + .equals(other.getSeqNum()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RESPCODE_FIELD_NUMBER; + hash = (53 * hash) + getRespCode().hashCode(); + hash = (37 * hash) + RESPMSG_FIELD_NUMBER; + hash = (53 * hash) + getRespMsg().hashCode(); + hash = (37 * hash) + RESPTIME_FIELD_NUMBER; + hash = (53 * hash) + getRespTime().hashCode(); + hash = (37 * hash) + SEQNUM_FIELD_NUMBER; + hash = (53 * hash) + getSeqNum().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static Response parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Response parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Response parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Response parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Response parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Response parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Response parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Response parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static Response parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static Response parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static Response parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Response parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(Response prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Response} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Response) + ResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Response.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Response.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + respCode_ = ""; + + respMsg_ = ""; + + respTime_ = ""; + + seqNum_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_descriptor; + } + + public Response getDefaultInstanceForType() { + return Response.getDefaultInstance(); + } + + public Response build() { + Response result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Response buildPartial() { + Response result = new Response(this); + result.respCode_ = respCode_; + result.respMsg_ = respMsg_; + result.respTime_ = respTime_; + result.seqNum_ = seqNum_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Response) { + return mergeFrom((Response)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Response other) { + if (other == Response.getDefaultInstance()) return this; + if (!other.getRespCode().isEmpty()) { + respCode_ = other.respCode_; + onChanged(); + } + if (!other.getRespMsg().isEmpty()) { + respMsg_ = other.respMsg_; + onChanged(); + } + if (!other.getRespTime().isEmpty()) { + respTime_ = other.respTime_; + onChanged(); + } + if (!other.getSeqNum().isEmpty()) { + seqNum_ = other.seqNum_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Response parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Response) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object respCode_ = ""; + /** + * string respCode = 1; + */ + public String getRespCode() { + Object ref = respCode_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respCode_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string respCode = 1; + */ + public com.google.protobuf.ByteString + getRespCodeBytes() { + Object ref = respCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string respCode = 1; + */ + public Builder setRespCode( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + respCode_ = value; + onChanged(); + return this; + } + /** + * string respCode = 1; + */ + public Builder clearRespCode() { + + respCode_ = getDefaultInstance().getRespCode(); + onChanged(); + return this; + } + /** + * string respCode = 1; + */ + public Builder setRespCodeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + respCode_ = value; + onChanged(); + return this; + } + + private Object respMsg_ = ""; + /** + * string respMsg = 2; + */ + public String getRespMsg() { + Object ref = respMsg_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respMsg_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string respMsg = 2; + */ + public com.google.protobuf.ByteString + getRespMsgBytes() { + Object ref = respMsg_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respMsg_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string respMsg = 2; + */ + public Builder setRespMsg( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + respMsg_ = value; + onChanged(); + return this; + } + /** + * string respMsg = 2; + */ + public Builder clearRespMsg() { + + respMsg_ = getDefaultInstance().getRespMsg(); + onChanged(); + return this; + } + /** + * string respMsg = 2; + */ + public Builder setRespMsgBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + respMsg_ = value; + onChanged(); + return this; + } + + private Object respTime_ = ""; + /** + * string respTime = 3; + */ + public String getRespTime() { + Object ref = respTime_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respTime_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string respTime = 3; + */ + public com.google.protobuf.ByteString + getRespTimeBytes() { + Object ref = respTime_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respTime_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string respTime = 3; + */ + public Builder setRespTime( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + respTime_ = value; + onChanged(); + return this; + } + /** + * string respTime = 3; + */ + public Builder clearRespTime() { + + respTime_ = getDefaultInstance().getRespTime(); + onChanged(); + return this; + } + /** + * string respTime = 3; + */ + public Builder setRespTimeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + respTime_ = value; + onChanged(); + return this; + } + + private Object seqNum_ = ""; + /** + * string seqNum = 4; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string seqNum = 4; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string seqNum = 4; + */ + public Builder setSeqNum( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + seqNum_ = value; + onChanged(); + return this; + } + /** + * string seqNum = 4; + */ + public Builder clearSeqNum() { + + seqNum_ = getDefaultInstance().getSeqNum(); + onChanged(); + return this; + } + /** + * string seqNum = 4; + */ + public Builder setSeqNumBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + seqNum_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Response) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Response) + private static final Response DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new Response(); + } + + public static Response getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Response parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Response(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Response getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java new file mode 100644 index 0000000000..701507deb9 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java @@ -0,0 +1,49 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public interface ResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Response) + com.google.protobuf.MessageOrBuilder { + + /** + * string respCode = 1; + */ + String getRespCode(); + /** + * string respCode = 1; + */ + com.google.protobuf.ByteString + getRespCodeBytes(); + + /** + * string respMsg = 2; + */ + String getRespMsg(); + /** + * string respMsg = 2; + */ + com.google.protobuf.ByteString + getRespMsgBytes(); + + /** + * string respTime = 3; + */ + String getRespTime(); + /** + * string respTime = 3; + */ + com.google.protobuf.ByteString + getRespTimeBytes(); + + /** + * string seqNum = 4; + */ + String getSeqNum(); + /** + * string seqNum = 4; + */ + com.google.protobuf.ByteString + getSeqNumBytes(); +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java new file mode 100644 index 0000000000..76efe7dc6c --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java @@ -0,0 +1,2077 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +/** + * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription} + */ +public final class Subscription extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Subscription) + SubscriptionOrBuilder { +private static final long serialVersionUID = 0L; + // Use Subscription.newBuilder() to construct. + private Subscription(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Subscription() { + consumerGroup_ = ""; + subscriptionItems_ = java.util.Collections.emptyList(); + url_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Subscription( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + RequestHeader.Builder subBuilder = null; + if (header_ != null) { + subBuilder = header_.toBuilder(); + } + header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(header_); + header_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + consumerGroup_ = s; + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + subscriptionItems_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + subscriptionItems_.add( + input.readMessage(SubscriptionItem.parser(), extensionRegistry)); + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + url_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + subscriptionItems_ = java.util.Collections.unmodifiableList(subscriptionItems_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Subscription.class, Builder.class); + } + + public interface SubscriptionItemOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem) + com.google.protobuf.MessageOrBuilder { + + /** + * string topic = 1; + */ + String getTopic(); + /** + * string topic = 1; + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; + */ + int getModeValue(); + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; + */ + SubscriptionItem.SubscriptionMode getMode(); + + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; + */ + int getTypeValue(); + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; + */ + SubscriptionItem.SubscriptionType getType(); + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem} + */ + public static final class SubscriptionItem extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem) + SubscriptionItemOrBuilder { + private static final long serialVersionUID = 0L; + // Use SubscriptionItem.newBuilder() to construct. + private SubscriptionItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SubscriptionItem() { + topic_ = ""; + mode_ = 0; + type_ = 0; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SubscriptionItem( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 16: { + int rawValue = input.readEnum(); + + mode_ = rawValue; + break; + } + case 24: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SubscriptionItem.class, Builder.class); + } + + /** + * Protobuf enum {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode} + */ + public enum SubscriptionMode + implements com.google.protobuf.ProtocolMessageEnum { + /** + * CLUSTERING = 0; + */ + CLUSTERING(0), + /** + * BROADCASTING = 1; + */ + BROADCASTING(1), + UNRECOGNIZED(-1), + ; + + /** + * CLUSTERING = 0; + */ + public static final int CLUSTERING_VALUE = 0; + /** + * BROADCASTING = 1; + */ + public static final int BROADCASTING_VALUE = 1; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @Deprecated + public static SubscriptionMode valueOf(int value) { + return forNumber(value); + } + + public static SubscriptionMode forNumber(int value) { + switch (value) { + case 0: return CLUSTERING; + case 1: return BROADCASTING; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + SubscriptionMode> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public SubscriptionMode findValueByNumber(int number) { + return SubscriptionMode.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return SubscriptionItem.getDescriptor().getEnumTypes().get(0); + } + + private static final SubscriptionMode[] VALUES = values(); + + public static SubscriptionMode valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private SubscriptionMode(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode) + } + + /** + * Protobuf enum {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType} + */ + public enum SubscriptionType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * ASYNC = 0; + */ + ASYNC(0), + /** + * SYNC = 1; + */ + SYNC(1), + UNRECOGNIZED(-1), + ; + + /** + * ASYNC = 0; + */ + public static final int ASYNC_VALUE = 0; + /** + * SYNC = 1; + */ + public static final int SYNC_VALUE = 1; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @Deprecated + public static SubscriptionType valueOf(int value) { + return forNumber(value); + } + + public static SubscriptionType forNumber(int value) { + switch (value) { + case 0: return ASYNC; + case 1: return SYNC; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + SubscriptionType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public SubscriptionType findValueByNumber(int number) { + return SubscriptionType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return SubscriptionItem.getDescriptor().getEnumTypes().get(1); + } + + private static final SubscriptionType[] VALUES = values(); + + public static SubscriptionType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private SubscriptionType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType) + } + + public static final int TOPIC_FIELD_NUMBER = 1; + private volatile Object topic_; + /** + * string topic = 1; + */ + public String getTopic() { + Object ref = topic_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int MODE_FIELD_NUMBER = 2; + private int mode_; + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; + */ + public int getModeValue() { + return mode_; + } + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; + */ + public SubscriptionMode getMode() { + SubscriptionMode result = SubscriptionMode.valueOf(mode_); + return result == null ? SubscriptionMode.UNRECOGNIZED : result; + } + + public static final int TYPE_FIELD_NUMBER = 3; + private int type_; + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; + */ + public int getTypeValue() { + return type_; + } + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; + */ + public SubscriptionType getType() { + SubscriptionType result = SubscriptionType.valueOf(type_); + return result == null ? SubscriptionType.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); + } + if (mode_ != SubscriptionMode.CLUSTERING.getNumber()) { + output.writeEnum(2, mode_); + } + if (type_ != SubscriptionType.ASYNC.getNumber()) { + output.writeEnum(3, type_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); + } + if (mode_ != SubscriptionMode.CLUSTERING.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, mode_); + } + if (type_ != SubscriptionType.ASYNC.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(3, type_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SubscriptionItem)) { + return super.equals(obj); + } + SubscriptionItem other = (SubscriptionItem) obj; + + boolean result = true; + result = result && getTopic() + .equals(other.getTopic()); + result = result && mode_ == other.mode_; + result = result && type_ == other.type_; + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TOPIC_FIELD_NUMBER; + hash = (53 * hash) + getTopic().hashCode(); + hash = (37 * hash) + MODE_FIELD_NUMBER; + hash = (53 * hash) + mode_; + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SubscriptionItem parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SubscriptionItem parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SubscriptionItem parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SubscriptionItem parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SubscriptionItem parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SubscriptionItem parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SubscriptionItem parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SubscriptionItem parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static SubscriptionItem parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static SubscriptionItem parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static SubscriptionItem parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SubscriptionItem parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(SubscriptionItem prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem) + SubscriptionItemOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SubscriptionItem.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + topic_ = ""; + + mode_ = 0; + + type_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor; + } + + public SubscriptionItem getDefaultInstanceForType() { + return SubscriptionItem.getDefaultInstance(); + } + + public SubscriptionItem build() { + SubscriptionItem result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public SubscriptionItem buildPartial() { + SubscriptionItem result = new SubscriptionItem(this); + result.topic_ = topic_; + result.mode_ = mode_; + result.type_ = type_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SubscriptionItem) { + return mergeFrom((SubscriptionItem)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SubscriptionItem other) { + if (other == SubscriptionItem.getDefaultInstance()) return this; + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (other.mode_ != 0) { + setModeValue(other.getModeValue()); + } + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + SubscriptionItem parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (SubscriptionItem) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object topic_ = ""; + /** + * string topic = 1; + */ + public String getTopic() { + Object ref = topic_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string topic = 1; + */ + public Builder setTopic( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * string topic = 1; + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * string topic = 1; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private int mode_ = 0; + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; + */ + public int getModeValue() { + return mode_; + } + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; + */ + public Builder setModeValue(int value) { + mode_ = value; + onChanged(); + return this; + } + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; + */ + public SubscriptionMode getMode() { + SubscriptionMode result = SubscriptionMode.valueOf(mode_); + return result == null ? SubscriptionMode.UNRECOGNIZED : result; + } + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; + */ + public Builder setMode(SubscriptionMode value) { + if (value == null) { + throw new NullPointerException(); + } + + mode_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; + */ + public Builder clearMode() { + + mode_ = 0; + onChanged(); + return this; + } + + private int type_ = 0; + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; + */ + public int getTypeValue() { + return type_; + } + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; + */ + public Builder setTypeValue(int value) { + type_ = value; + onChanged(); + return this; + } + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; + */ + public SubscriptionType getType() { + SubscriptionType result = SubscriptionType.valueOf(type_); + return result == null ? SubscriptionType.UNRECOGNIZED : result; + } + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; + */ + public Builder setType(SubscriptionType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem) + private static final SubscriptionItem DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SubscriptionItem(); + } + + public static SubscriptionItem getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public SubscriptionItem parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SubscriptionItem(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public SubscriptionItem getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int HEADER_FIELD_NUMBER = 1; + private RequestHeader header_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + return getHeader(); + } + + public static final int CONSUMERGROUP_FIELD_NUMBER = 2; + private volatile Object consumerGroup_; + /** + * string consumerGroup = 2; + */ + public String getConsumerGroup() { + Object ref = consumerGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + consumerGroup_ = s; + return s; + } + } + /** + * string consumerGroup = 2; + */ + public com.google.protobuf.ByteString + getConsumerGroupBytes() { + Object ref = consumerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + consumerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SUBSCRIPTIONITEMS_FIELD_NUMBER = 3; + private java.util.List subscriptionItems_; + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List getSubscriptionItemsList() { + return subscriptionItems_; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List + getSubscriptionItemsOrBuilderList() { + return subscriptionItems_; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public int getSubscriptionItemsCount() { + return subscriptionItems_.size(); + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem getSubscriptionItems(int index) { + return subscriptionItems_.get(index); + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( + int index) { + return subscriptionItems_.get(index); + } + + public static final int URL_FIELD_NUMBER = 4; + private volatile Object url_; + /** + * string url = 4; + */ + public String getUrl() { + Object ref = url_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } + } + /** + * string url = 4; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (header_ != null) { + output.writeMessage(1, getHeader()); + } + if (!getConsumerGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, consumerGroup_); + } + for (int i = 0; i < subscriptionItems_.size(); i++) { + output.writeMessage(3, subscriptionItems_.get(i)); + } + if (!getUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, url_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (header_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getHeader()); + } + if (!getConsumerGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, consumerGroup_); + } + for (int i = 0; i < subscriptionItems_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, subscriptionItems_.get(i)); + } + if (!getUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, url_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Subscription)) { + return super.equals(obj); + } + Subscription other = (Subscription) obj; + + boolean result = true; + result = result && (hasHeader() == other.hasHeader()); + if (hasHeader()) { + result = result && getHeader() + .equals(other.getHeader()); + } + result = result && getConsumerGroup() + .equals(other.getConsumerGroup()); + result = result && getSubscriptionItemsList() + .equals(other.getSubscriptionItemsList()); + result = result && getUrl() + .equals(other.getUrl()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasHeader()) { + hash = (37 * hash) + HEADER_FIELD_NUMBER; + hash = (53 * hash) + getHeader().hashCode(); + } + hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER; + hash = (53 * hash) + getConsumerGroup().hashCode(); + if (getSubscriptionItemsCount() > 0) { + hash = (37 * hash) + SUBSCRIPTIONITEMS_FIELD_NUMBER; + hash = (53 * hash) + getSubscriptionItemsList().hashCode(); + } + hash = (37 * hash) + URL_FIELD_NUMBER; + hash = (53 * hash) + getUrl().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static Subscription parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Subscription parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Subscription parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Subscription parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Subscription parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Subscription parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Subscription parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Subscription parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static Subscription parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static Subscription parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static Subscription parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Subscription parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(Subscription prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Subscription) + SubscriptionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Subscription.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Subscription.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getSubscriptionItemsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (headerBuilder_ == null) { + header_ = null; + } else { + header_ = null; + headerBuilder_ = null; + } + consumerGroup_ = ""; + + if (subscriptionItemsBuilder_ == null) { + subscriptionItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + subscriptionItemsBuilder_.clear(); + } + url_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor; + } + + public Subscription getDefaultInstanceForType() { + return Subscription.getDefaultInstance(); + } + + public Subscription build() { + Subscription result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Subscription buildPartial() { + Subscription result = new Subscription(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (headerBuilder_ == null) { + result.header_ = header_; + } else { + result.header_ = headerBuilder_.build(); + } + result.consumerGroup_ = consumerGroup_; + if (subscriptionItemsBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + subscriptionItems_ = java.util.Collections.unmodifiableList(subscriptionItems_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.subscriptionItems_ = subscriptionItems_; + } else { + result.subscriptionItems_ = subscriptionItemsBuilder_.build(); + } + result.url_ = url_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Subscription) { + return mergeFrom((Subscription)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Subscription other) { + if (other == Subscription.getDefaultInstance()) return this; + if (other.hasHeader()) { + mergeHeader(other.getHeader()); + } + if (!other.getConsumerGroup().isEmpty()) { + consumerGroup_ = other.consumerGroup_; + onChanged(); + } + if (subscriptionItemsBuilder_ == null) { + if (!other.subscriptionItems_.isEmpty()) { + if (subscriptionItems_.isEmpty()) { + subscriptionItems_ = other.subscriptionItems_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.addAll(other.subscriptionItems_); + } + onChanged(); + } + } else { + if (!other.subscriptionItems_.isEmpty()) { + if (subscriptionItemsBuilder_.isEmpty()) { + subscriptionItemsBuilder_.dispose(); + subscriptionItemsBuilder_ = null; + subscriptionItems_ = other.subscriptionItems_; + bitField0_ = (bitField0_ & ~0x00000004); + subscriptionItemsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSubscriptionItemsFieldBuilder() : null; + } else { + subscriptionItemsBuilder_.addAllMessages(other.subscriptionItems_); + } + } + } + if (!other.getUrl().isEmpty()) { + url_ = other.url_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Subscription parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Subscription) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private RequestHeader header_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return headerBuilder_ != null || header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + if (headerBuilder_ == null) { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } else { + return headerBuilder_.getMessage(); + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + header_ = value; + onChanged(); + } else { + headerBuilder_.setMessage(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader( + RequestHeader.Builder builderForValue) { + if (headerBuilder_ == null) { + header_ = builderForValue.build(); + onChanged(); + } else { + headerBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder mergeHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (header_ != null) { + header_ = + RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); + } else { + header_ = value; + } + onChanged(); + } else { + headerBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder clearHeader() { + if (headerBuilder_ == null) { + header_ = null; + onChanged(); + } else { + header_ = null; + headerBuilder_ = null; + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader.Builder getHeaderBuilder() { + + onChanged(); + return getHeaderFieldBuilder().getBuilder(); + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + if (headerBuilder_ != null) { + return headerBuilder_.getMessageOrBuilder(); + } else { + return header_ == null ? + RequestHeader.getDefaultInstance() : header_; + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> + getHeaderFieldBuilder() { + if (headerBuilder_ == null) { + headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( + getHeader(), + getParentForChildren(), + isClean()); + header_ = null; + } + return headerBuilder_; + } + + private Object consumerGroup_ = ""; + /** + * string consumerGroup = 2; + */ + public String getConsumerGroup() { + Object ref = consumerGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + consumerGroup_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string consumerGroup = 2; + */ + public com.google.protobuf.ByteString + getConsumerGroupBytes() { + Object ref = consumerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + consumerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string consumerGroup = 2; + */ + public Builder setConsumerGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + consumerGroup_ = value; + onChanged(); + return this; + } + /** + * string consumerGroup = 2; + */ + public Builder clearConsumerGroup() { + + consumerGroup_ = getDefaultInstance().getConsumerGroup(); + onChanged(); + return this; + } + /** + * string consumerGroup = 2; + */ + public Builder setConsumerGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + consumerGroup_ = value; + onChanged(); + return this; + } + + private java.util.List subscriptionItems_ = + java.util.Collections.emptyList(); + private void ensureSubscriptionItemsIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + subscriptionItems_ = new java.util.ArrayList(subscriptionItems_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder> subscriptionItemsBuilder_; + + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List getSubscriptionItemsList() { + if (subscriptionItemsBuilder_ == null) { + return java.util.Collections.unmodifiableList(subscriptionItems_); + } else { + return subscriptionItemsBuilder_.getMessageList(); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public int getSubscriptionItemsCount() { + if (subscriptionItemsBuilder_ == null) { + return subscriptionItems_.size(); + } else { + return subscriptionItemsBuilder_.getCount(); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem getSubscriptionItems(int index) { + if (subscriptionItemsBuilder_ == null) { + return subscriptionItems_.get(index); + } else { + return subscriptionItemsBuilder_.getMessage(index); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder setSubscriptionItems( + int index, SubscriptionItem value) { + if (subscriptionItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.set(index, value); + onChanged(); + } else { + subscriptionItemsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder setSubscriptionItems( + int index, SubscriptionItem.Builder builderForValue) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.set(index, builderForValue.build()); + onChanged(); + } else { + subscriptionItemsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addSubscriptionItems(SubscriptionItem value) { + if (subscriptionItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.add(value); + onChanged(); + } else { + subscriptionItemsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addSubscriptionItems( + int index, SubscriptionItem value) { + if (subscriptionItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.add(index, value); + onChanged(); + } else { + subscriptionItemsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addSubscriptionItems( + SubscriptionItem.Builder builderForValue) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.add(builderForValue.build()); + onChanged(); + } else { + subscriptionItemsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addSubscriptionItems( + int index, SubscriptionItem.Builder builderForValue) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.add(index, builderForValue.build()); + onChanged(); + } else { + subscriptionItemsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addAllSubscriptionItems( + Iterable values) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, subscriptionItems_); + onChanged(); + } else { + subscriptionItemsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder clearSubscriptionItems() { + if (subscriptionItemsBuilder_ == null) { + subscriptionItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + subscriptionItemsBuilder_.clear(); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder removeSubscriptionItems(int index) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.remove(index); + onChanged(); + } else { + subscriptionItemsBuilder_.remove(index); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem.Builder getSubscriptionItemsBuilder( + int index) { + return getSubscriptionItemsFieldBuilder().getBuilder(index); + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( + int index) { + if (subscriptionItemsBuilder_ == null) { + return subscriptionItems_.get(index); } else { + return subscriptionItemsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List + getSubscriptionItemsOrBuilderList() { + if (subscriptionItemsBuilder_ != null) { + return subscriptionItemsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(subscriptionItems_); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem.Builder addSubscriptionItemsBuilder() { + return getSubscriptionItemsFieldBuilder().addBuilder( + SubscriptionItem.getDefaultInstance()); + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem.Builder addSubscriptionItemsBuilder( + int index) { + return getSubscriptionItemsFieldBuilder().addBuilder( + index, SubscriptionItem.getDefaultInstance()); + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List + getSubscriptionItemsBuilderList() { + return getSubscriptionItemsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder> + getSubscriptionItemsFieldBuilder() { + if (subscriptionItemsBuilder_ == null) { + subscriptionItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder>( + subscriptionItems_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + subscriptionItems_ = null; + } + return subscriptionItemsBuilder_; + } + + private Object url_ = ""; + /** + * string url = 4; + */ + public String getUrl() { + Object ref = url_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string url = 4; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string url = 4; + */ + public Builder setUrl( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + /** + * string url = 4; + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + /** + * string url = 4; + */ + public Builder setUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + url_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Subscription) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Subscription) + private static final Subscription DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new Subscription(); + } + + public static Subscription getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Subscription parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Subscription(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Subscription getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java new file mode 100644 index 0000000000..2f98079eb6 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java @@ -0,0 +1,66 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public interface SubscriptionOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Subscription) + com.google.protobuf.MessageOrBuilder { + + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + boolean hasHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeader getHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeaderOrBuilder getHeaderOrBuilder(); + + /** + * string consumerGroup = 2; + */ + String getConsumerGroup(); + /** + * string consumerGroup = 2; + */ + com.google.protobuf.ByteString + getConsumerGroupBytes(); + + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + java.util.List + getSubscriptionItemsList(); + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + Subscription.SubscriptionItem getSubscriptionItems(int index); + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + int getSubscriptionItemsCount(); + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + java.util.List + getSubscriptionItemsOrBuilderList(); + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + Subscription.SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( + int index); + + /** + * string url = 4; + */ + String getUrl(); + /** + * string url = 4; + */ + com.google.protobuf.ByteString + getUrlBytes(); +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/command/HttpCommand.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/HttpCommand.java similarity index 82% rename from eventmesh-common/src/main/java/org/apache/eventmesh/common/command/HttpCommand.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/HttpCommand.java index b6c61d68df..4b2d7b5816 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/command/HttpCommand.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/HttpCommand.java @@ -15,19 +15,20 @@ * limitations under the License. */ -package org.apache.eventmesh.common.command; +package org.apache.eventmesh.common.protocol.http; import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; import org.apache.eventmesh.common.protocol.http.body.BaseResponseBody; import org.apache.eventmesh.common.protocol.http.body.Body; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; import org.apache.eventmesh.common.protocol.http.header.BaseResponseHeader; import org.apache.eventmesh.common.protocol.http.header.Header; import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; -import java.util.Map; +import java.util.Optional; import java.util.concurrent.atomic.AtomicLong; import io.netty.buffer.Unpooled; @@ -38,9 +39,9 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpVersion; -public class HttpCommand { +public class HttpCommand implements ProtocolTransportObject { - private static AtomicLong requestId = new AtomicLong(0); + private static final AtomicLong requestId = new AtomicLong(0); private long opaque; @@ -63,8 +64,7 @@ public class HttpCommand { public CmdType cmdType = CmdType.REQ; public HttpCommand() { - this.reqTime = System.currentTimeMillis(); - this.opaque = requestId.incrementAndGet(); + this(null, null, null); } public HttpCommand(String httpMethod, String httpVersion, String requestCode) { @@ -75,8 +75,7 @@ public HttpCommand(String httpMethod, String httpVersion, String requestCode) { this.opaque = requestId.incrementAndGet(); } - public HttpCommand createHttpCommandResponse(Header header, - Body body) { + public HttpCommand createHttpCommandResponse(Header header, Body body) { if (StringUtils.isBlank(requestCode)) { return null; } @@ -90,7 +89,7 @@ public HttpCommand createHttpCommandResponse(Header header, return response; } - public HttpCommand createHttpCommandResponse(Integer retCode, String retMsg) { + public HttpCommand createHttpCommandResponse(EventMeshRetCode eventMeshRetCode) { if (StringUtils.isBlank(requestCode)) { return null; } @@ -101,8 +100,8 @@ public HttpCommand createHttpCommandResponse(Integer retCode, String retMsg) { baseResponseHeader.setCode(requestCode); response.setHeader(baseResponseHeader); BaseResponseBody baseResponseBody = new BaseResponseBody(); - baseResponseBody.setRetCode(retCode); - baseResponseBody.setRetMsg(retMsg); + baseResponseBody.setRetCode(eventMeshRetCode.getRetCode()); + baseResponseBody.setRetMsg(eventMeshRetCode.getErrMsg()); response.setBody(baseResponseBody); response.setCmdType(CmdType.RES); response.setResTime(System.currentTimeMillis()); @@ -233,22 +232,13 @@ public DefaultFullHttpResponse httpResponse() throws Exception { if (cmdType == CmdType.REQ) { return null; } - - DefaultFullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, - HttpResponseStatus.OK, - Unpooled.wrappedBuffer( - JsonUtils.serialize(this.getBody()).getBytes(Constants.DEFAULT_CHARSET))); - response.headers().add(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN + - "; charset=" + Constants.DEFAULT_CHARSET); - response.headers().add(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes()); - response.headers().add(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE); - Map customHeader = this.getHeader().toMap(); - if (MapUtils.isNotEmpty(customHeader)) { - HttpHeaders heads = response.headers(); - for (String key : customHeader.keySet()) { - heads.add(key, (customHeader.get(key) == null) ? "" : customHeader.get(key)); - } - } + DefaultFullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, + Unpooled.wrappedBuffer(JsonUtils.serialize(this.getBody()).getBytes(Constants.DEFAULT_CHARSET))); + HttpHeaders headers = response.headers(); + headers.add(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=" + Constants.DEFAULT_CHARSET); + headers.add(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes()); + headers.add(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE); + Optional.of(this.getHeader().toMap()).ifPresent(customerHeader -> customerHeader.forEach(headers::add)); return response; } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java index fad1e95160..8e24580f39 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java @@ -32,7 +32,7 @@ public class PushMessageRequestBody extends Body { public static final String RANDOMNO = "randomNo"; public static final String TOPIC = "topic"; - public static final String BIZSEQNO = "bizSeqNo"; + public static final String BIZSEQNO = "bizseqno"; public static final String UNIQUEID = "uniqueId"; public static final String CONTENT = "content"; public static final String EXTFIELDS = "extFields"; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java index 93fa8b5f9a..90d83c1531 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java @@ -30,12 +30,12 @@ public class ReplyMessageRequestBody extends Body { - public static final String ORIGTOPIC = "origTopic"; - public static final String BIZSEQNO = "bizSeqNo"; - public static final String UNIQUEID = "uniqueId"; + public static final String ORIGTOPIC = "origtopic"; + public static final String BIZSEQNO = "bizseqno"; + public static final String UNIQUEID = "uniqueid"; public static final String CONTENT = "content"; public static final String EXTFIELDS = "extFields"; - public static final String PRODUCERGROUP = "producerGroup"; + public static final String PRODUCERGROUP = "producergroup"; private String bizSeqNo; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java index 8f97cf16c0..b08dca7b0c 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java @@ -25,12 +25,12 @@ public class SendMessageBatchV2RequestBody extends Body { - public static final String BIZSEQNO = "bizSeqNo"; + public static final String BIZSEQNO = "bizseqno"; public static final String TOPIC = "topic"; public static final String MSG = "msg"; public static final String TAG = "tag"; public static final String TTL = "ttl"; - public static final String PRODUCERGROUP = "producerGroup"; + public static final String PRODUCERGROUP = "producergroup"; private String bizSeqNo; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java index 196a9ccb84..25d35922a3 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java @@ -31,13 +31,13 @@ public class SendMessageRequestBody extends Body { public static final String TOPIC = "topic"; - public static final String BIZSEQNO = "bizSeqNo"; - public static final String UNIQUEID = "uniqueId"; + public static final String BIZSEQNO = "bizseqno"; + public static final String UNIQUEID = "uniqueid"; public static final String CONTENT = "content"; public static final String TTL = "ttl"; public static final String TAG = "tag"; public static final String EXTFIELDS = "extFields"; - public static final String PRODUCERGROUP = "producerGroup"; + public static final String PRODUCERGROUP = "producergroup"; private String topic; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java index b9175a2c74..7a5f40dabd 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java @@ -17,14 +17,18 @@ package org.apache.eventmesh.common.protocol.http.body.message; -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.http.body.Body; import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.commons.lang3.time.DateFormatUtils; + +import java.util.HashMap; +import java.util.Map; + +import lombok.Builder; +import lombok.Data; + public class SendMessageResponseBody extends Body { private Integer retCode; @@ -69,9 +73,9 @@ public static SendMessageResponseBody buildBody(Integer retCode, String retMsg) public String toString() { StringBuilder sb = new StringBuilder(); sb.append("sendMessageResponseBody={") - .append("retCode=").append(retCode).append(",") - .append("retMsg=").append(retMsg).append(",") - .append("resTime=").append(DateFormatUtils.format(resTime, Constants.DATE_FORMAT)).append("}"); + .append("retCode=").append(retCode).append(",") + .append("retMsg=").append(retMsg).append(",") + .append("resTime=").append(DateFormatUtils.format(resTime, Constants.DATE_FORMAT)).append("}"); return sb.toString(); } @@ -84,15 +88,11 @@ public Map toMap() { return map; } + @Data + @Builder public static class ReplyMessage { - public String topic; - public String body; + public String topic; + public String body; public Map properties; - - public ReplyMessage(String topic, String body, Map properties) { - this.topic = topic; - this.body = body; - this.properties = properties; - } } } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java index 28e944ea30..e032f1fe9a 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java @@ -19,28 +19,36 @@ public class ProtocolKey { - public static final String REQUEST_CODE = "Code"; - public static final String LANGUAGE = "Language"; - public static final String VERSION = "Version"; + public static final String REQUEST_CODE = "code"; + public static final String LANGUAGE = "language"; + public static final String VERSION = "version"; + + public static final String PROTOCOL_TYPE = "protocoltype"; + + public static final String PROTOCOL_VERSION = "protocolversion"; + + public static final String PROTOCOL_DESC = "protocoldesc"; public static class ClientInstanceKey { ////////////////////////////////////Protocol layer requester description/////////// - public static final String ENV = "Env"; - public static final String IDC = "Idc"; - public static final String SYS = "Sys"; - public static final String PID = "Pid"; - public static final String IP = "Ip"; - public static final String USERNAME = "Username"; - public static final String PASSWD = "Passwd"; + public static final String ENV = "env"; + public static final String IDC = "idc"; + public static final String SYS = "sys"; + public static final String PID = "pid"; + public static final String IP = "ip"; + public static final String USERNAME = "username"; + public static final String PASSWD = "passwd"; + public static final String BIZSEQNO = "bizseqno"; + public static final String UNIQUEID = "uniqueid"; } public static class EventMeshInstanceKey { ///////////////////////////////////////////////Protocol layer EventMesh description - public static final String EVENTMESHCLUSTER = "EventMeshCluster"; - public static final String EVENTMESHIP = "EventMeshIp"; - public static final String EVENTMESHENV = "EventMeshEnv"; - public static final String EVENTMESHIDC = "EventMeshIdc"; + public static final String EVENTMESHCLUSTER = "eventmeshcluster"; + public static final String EVENTMESHIP = "eventmeship"; + public static final String EVENTMESHENV = "eventmeshenv"; + public static final String EVENTMESHIDC = "eventmeshidc"; } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java index d25936e279..496b1906cc 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java @@ -38,6 +38,15 @@ public class ReplyMessageRequestHeader extends Header { //protocol version adopted by requester, default:1.0 private ProtocolVersion version; + //protocol type, cloudevents or eventmeshMessage + private String protocolType; + + //protocol version, cloudevents:1.0 or 0.3 + private String protocolVersion; + + //protocol desc + private String protocolDesc; + //the environment number of the requester private String env; @@ -139,10 +148,37 @@ public void setIp(String ip) { this.ip = ip; } + public String getProtocolType() { + return protocolType; + } + + public void setProtocolType(String protocolType) { + this.protocolType = protocolType; + } + + public String getProtocolVersion() { + return protocolVersion; + } + + public void setProtocolVersion(String protocolVersion) { + this.protocolVersion = protocolVersion; + } + + public String getProtocolDesc() { + return protocolDesc; + } + + public void setProtocolDesc(String protocolDesc) { + this.protocolDesc = protocolDesc; + } + public static ReplyMessageRequestHeader buildHeader(Map headerParam) { ReplyMessageRequestHeader header = new ReplyMessageRequestHeader(); header.setCode(MapUtils.getString(headerParam, ProtocolKey.REQUEST_CODE)); header.setVersion(ProtocolVersion.get(MapUtils.getString(headerParam, ProtocolKey.VERSION))); + header.setProtocolType(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_TYPE)); + header.setProtocolVersion(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_VERSION)); + header.setProtocolDesc(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_DESC)); String lan = StringUtils.isBlank(MapUtils.getString(headerParam, ProtocolKey.LANGUAGE)) ? Constants.LANGUAGE_JAVA : MapUtils.getString(headerParam, ProtocolKey.LANGUAGE); header.setLanguage(lan); diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java index 62cafa4226..85492cf2fc 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java @@ -39,6 +39,15 @@ public class SendMessageBatchRequestHeader extends Header { //protocol version adopted by requester, default:1.0 private ProtocolVersion version; + //protocol type, cloudevents or eventmeshMessage + private String protocolType; + + //protocol version, cloudevents:1.0 or 0.3 + private String protocolVersion; + + //protocol desc + private String protocolDesc; + //the environment number of the requester private String env; @@ -140,10 +149,37 @@ public void setIp(String ip) { this.ip = ip; } + public String getProtocolType() { + return protocolType; + } + + public void setProtocolType(String protocolType) { + this.protocolType = protocolType; + } + + public String getProtocolVersion() { + return protocolVersion; + } + + public void setProtocolVersion(String protocolVersion) { + this.protocolVersion = protocolVersion; + } + + public String getProtocolDesc() { + return protocolDesc; + } + + public void setProtocolDesc(String protocolDesc) { + this.protocolDesc = protocolDesc; + } + public static SendMessageBatchRequestHeader buildHeader(final Map headerParam) { SendMessageBatchRequestHeader header = new SendMessageBatchRequestHeader(); header.setCode(MapUtils.getString(headerParam, ProtocolKey.REQUEST_CODE)); header.setVersion(ProtocolVersion.get(MapUtils.getString(headerParam, ProtocolKey.VERSION))); + header.setProtocolType(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_TYPE)); + header.setProtocolVersion(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_VERSION)); + header.setProtocolDesc(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_DESC)); String lan = StringUtils.isBlank(MapUtils.getString(headerParam, ProtocolKey.LANGUAGE)) ? Constants.LANGUAGE_JAVA : MapUtils.getString(headerParam, ProtocolKey.LANGUAGE); header.setLanguage(lan); diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java index b5d2e145e3..15ff19a623 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java @@ -38,6 +38,15 @@ public class SendMessageBatchV2RequestHeader extends Header { //protocol version adopted by requester, default:1.0 private ProtocolVersion version; + //protocol type, cloudevents or eventmeshMessage + private String protocolType; + + //protocol version, cloudevents:1.0 or 0.3 + private String protocolVersion; + + //protocol desc + private String protocolDesc; + //the environment number of the requester private String env; @@ -139,10 +148,38 @@ public void setIp(String ip) { this.ip = ip; } + public String getProtocolType() { + return protocolType; + } + + public void setProtocolType(String protocolType) { + this.protocolType = protocolType; + } + + public String getProtocolVersion() { + return protocolVersion; + } + + public void setProtocolVersion(String protocolVersion) { + this.protocolVersion = protocolVersion; + } + + public String getProtocolDesc() { + return protocolDesc; + } + + public void setProtocolDesc(String protocolDesc) { + this.protocolDesc = protocolDesc; + } + public static SendMessageBatchV2RequestHeader buildHeader(final Map headerParam) { SendMessageBatchV2RequestHeader header = new SendMessageBatchV2RequestHeader(); header.setCode(MapUtils.getString(headerParam, ProtocolKey.REQUEST_CODE)); header.setVersion(ProtocolVersion.get(MapUtils.getString(headerParam, ProtocolKey.VERSION))); + header.setProtocolType(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_TYPE)); + header.setProtocolVersion(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_VERSION)); + header.setProtocolDesc(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_DESC)); + String lan = StringUtils.isBlank(MapUtils.getString(headerParam, ProtocolKey.LANGUAGE)) ? Constants.LANGUAGE_JAVA : MapUtils.getString(headerParam, ProtocolKey.LANGUAGE); header.setLanguage(lan); diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java index 0eeea9afc2..f637563dc5 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java @@ -38,6 +38,15 @@ public class SendMessageRequestHeader extends Header { //protocol version adopted by requester, default:1.0 private ProtocolVersion version; + //protocol type, cloudevents or eventmeshMessage + private String protocolType; + + //protocol version, cloudevents:1.0 or 0.3 + private String protocolVersion; + + //protocol desc + private String protocolDesc; + //the environment number of the requester private String env; @@ -139,10 +148,38 @@ public void setIp(String ip) { this.ip = ip; } + public String getProtocolType() { + return protocolType; + } + + public void setProtocolType(String protocolType) { + this.protocolType = protocolType; + } + + public String getProtocolVersion() { + return protocolVersion; + } + + public void setProtocolVersion(String protocolVersion) { + this.protocolVersion = protocolVersion; + } + + public String getProtocolDesc() { + return protocolDesc; + } + + public void setProtocolDesc(String protocolDesc) { + this.protocolDesc = protocolDesc; + } + public static SendMessageRequestHeader buildHeader(Map headerParam) { SendMessageRequestHeader header = new SendMessageRequestHeader(); header.setCode(MapUtils.getString(headerParam, ProtocolKey.REQUEST_CODE)); header.setVersion(ProtocolVersion.get(MapUtils.getString(headerParam, ProtocolKey.VERSION))); + header.setProtocolType(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_TYPE)); + header.setProtocolVersion(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_VERSION)); + header.setProtocolDesc(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_DESC)); + String lan = StringUtils.isBlank(MapUtils.getString(headerParam, ProtocolKey.LANGUAGE)) ? Constants.LANGUAGE_JAVA : MapUtils.getString(headerParam, ProtocolKey.LANGUAGE); header.setLanguage(lan); diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshMessage.java index 01d744eea1..a51f9e022a 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshMessage.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshMessage.java @@ -20,51 +20,16 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -public class EventMeshMessage { - - private String topic; - Map properties = new ConcurrentHashMap<>(); - private String body; - - public EventMeshMessage() { - } - - public EventMeshMessage(String topic, Map properties, String body) { - this.topic = topic; - this.properties = properties; - this.body = body; - } - - public String getTopic() { - return topic; - } +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; - public void setTopic(String topic) { - this.topic = topic; - } - - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - - public String getBody() { - return body; - } - - public void setBody(String body) { - this.body = body; - } +@Data +@NoArgsConstructor +@AllArgsConstructor +public class EventMeshMessage { - @Override - public String toString() { - return "EventMeshMessage{" + - "topic='" + topic + '\'' + - ", properties=" + properties + - ", body='" + body + '\'' + - '}'; - } + private String topic; + private Map properties = new ConcurrentHashMap<>(); + private String body; } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Header.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Header.java index 1df51427c8..dc8e564382 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Header.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Header.java @@ -17,62 +17,59 @@ package org.apache.eventmesh.common.protocol.tcp; +import java.util.HashMap; +import java.util.Map; + +import lombok.Data; + +@Data public class Header { - private Command cmd; - private int code; - private String msg; - private String seq; + private Command cmd; + private int code; + private String desc; + private String seq; + private Map properties = new HashMap<>(); public Header() { } - public Header(Command cmd, int code, String msg, String seq) { + public Header(Command cmd, int code, String desc, String seq) { this.cmd = cmd; this.code = code; - this.msg = msg; + this.desc = desc; this.seq = seq; } - public Command getCommand() { - return cmd; - } - - public void setCommand(Command cmd) { - this.cmd = cmd; - } - - public int getCode() { - return code; - } - - public void setCode(int code) { + public Header(int code, String desc, String seq, Map properties) { this.code = code; + this.desc = desc; + this.seq = seq; + this.properties = properties; } - public String getMsg() { - return msg; - } - public void setMsg(String msg) { - this.msg = msg; - } + public void putProperty(final String name, final Object value) { + if (null == this.properties) { + this.properties = new HashMap<>(); + } - public String getSeq() { - return seq; + this.properties.put(name, value); } - public void setSeq(String seq) { - this.seq = seq; + public Object getProperty(final String name) { + if (null == this.properties) { + return null; + } + return this.properties.get(name); } - @Override - public String toString() { - return "Header{" + - "cmd=" + cmd + - ", code=" + code + - ", msg='" + msg + '\'' + - ", seq='" + seq + '\'' + - '}'; + public String getStringProperty(final String name) { + Object property = getProperty(name); + if (null == property) { + return null; + } + return property.toString(); } + } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Package.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Package.java index d2cde02193..1a2a223bf2 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Package.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Package.java @@ -17,44 +17,22 @@ package org.apache.eventmesh.common.protocol.tcp; -public class Package { +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Package implements ProtocolTransportObject { private Header header; private Object body; - public Package() { - } - public Package(Header header) { this.header = header; } - public Package(Header header, Object body) { - this.header = header; - this.body = body; - } - - public Header getHeader() { - return header; - } - - public void setHeader(Header header) { - this.header = header; - } - - public Object getBody() { - return body; - } - - public void setBody(Object body) { - this.body = body; - } - - @Override - public String toString() { - return "Package{" + - "header=" + header + - ", body=" + body + - '}'; - } } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UserAgent.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UserAgent.java index 14b5058e69..1d0c8d3fad 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UserAgent.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UserAgent.java @@ -17,14 +17,21 @@ package org.apache.eventmesh.common.protocol.tcp; +import lombok.Builder; +import lombok.Data; + +import java.util.Objects; + +@Data +@Builder public class UserAgent { private String env; private String subsystem; private String path; - private int pid; + private int pid; private String host; - private int port; + private int port; private String version; private String username; private String password; @@ -32,137 +39,36 @@ public class UserAgent { private String producerGroup; private String consumerGroup; private String purpose; - private int unack = 0; + @Builder.Default + private int unack = 0; public UserAgent() { } - public String getProducerGroup() { - return producerGroup; - } - - public void setProducerGroup(String producerGroup) { - this.producerGroup = producerGroup; - } - - public String getConsumerGroup() { - return consumerGroup; - } - - public void setConsumerGroup(String consumerGroup) { - this.consumerGroup = consumerGroup; - } - - public String getEnv() { - return env; - } - - public void setEnv(String env) { + public UserAgent(String env, String subsystem, String path, int pid, String host, int port, String version, + String username, String password, String idc, String producerGroup, String consumerGroup, + String purpose, int unack) { this.env = env; - } - - public String getPurpose() { - return purpose; - } - - public void setPurpose(String purpose) { - this.purpose = purpose; - } - - public String getSubsystem() { - return subsystem; - } - - public void setSubsystem(String subsystem) { this.subsystem = subsystem; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { this.path = path; - } - - public int getPid() { - return pid; - } - - public void setPid(int pid) { this.pid = pid; - } - - public String getHost() { - return host; - } - - public void setHost(String host) { this.host = host; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { this.port = port; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { this.version = version; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { this.password = password; - } - - public String getIdc() { - return idc; - } - - public void setIdc(String idc) { this.idc = idc; - } - - public int getUnack() { - return unack; - } - - public void setUnack(int unack) { + this.producerGroup = producerGroup; + this.consumerGroup = consumerGroup; + this.purpose = purpose; this.unack = unack; } @Override public String toString() { - return "UserAgent{" + - "env='" + env + '\'' + - "subsystem='" + subsystem + '\'' + - ", path='" + path + '\'' + - ", pid=" + pid + - ", host='" + host + '\'' + - ", port=" + port + - ", version='" + version + '\'' + - ", idc='" + idc + '\'' + - ", purpose='" + purpose + '\'' + - ", unack='" + unack + '\'' + - '}'; + return String.format( + "UserAgent{env='%s', subsystem='%s', path='%s', pid=%d, host='%s', port=%d, version='%s', idc='%s', purpose='%s', unack='%d'}", + env, subsystem, path, pid, host, port, version, idc, purpose, unack); } @Override @@ -175,15 +81,15 @@ public boolean equals(Object o) { if (pid != userAgent.pid) return false; if (port != userAgent.port) return false; if (unack != userAgent.unack) return false; - if (subsystem != null ? !subsystem.equals(userAgent.subsystem) : userAgent.subsystem != null) return false; - if (path != null ? !path.equals(userAgent.path) : userAgent.path != null) return false; - if (host != null ? !host.equals(userAgent.host) : userAgent.host != null) return false; - if (purpose != null ? !purpose.equals(userAgent.purpose) : userAgent.purpose != null) return false; - if (version != null ? !version.equals(userAgent.version) : userAgent.version != null) return false; - if (username != null ? !username.equals(userAgent.username) : userAgent.username != null) return false; - if (password != null ? !password.equals(userAgent.password) : userAgent.password != null) return false; - if (env != null ? !env.equals(userAgent.env) : userAgent.env != null) return false; - return idc != null ? idc.equals(userAgent.idc) : userAgent.idc == null; + if (!Objects.equals(subsystem, userAgent.subsystem)) return false; + if (!Objects.equals(path, userAgent.path)) return false; + if (!Objects.equals(host, userAgent.host)) return false; + if (!Objects.equals(purpose, userAgent.purpose)) return false; + if (!Objects.equals(version, userAgent.version)) return false; + if (!Objects.equals(username, userAgent.username)) return false; + if (!Objects.equals(password, userAgent.password)) return false; + if (!Objects.equals(env, userAgent.env)) return false; + return Objects.equals(idc, userAgent.idc); } @Override diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java index d520e04dbc..ab1d461207 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java @@ -17,67 +17,82 @@ package org.apache.eventmesh.common.protocol.tcp.codec; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.Header; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.RedirectInfo; +import org.apache.eventmesh.common.protocol.tcp.Subscription; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.common.utils.JsonUtils; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; + import java.nio.charset.Charset; import java.util.Arrays; import java.util.List; import java.util.TimeZone; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.ReplayingDecoder; +import lombok.extern.slf4j.Slf4j; -import org.apache.eventmesh.common.protocol.tcp.Command; -import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; -import org.apache.eventmesh.common.protocol.tcp.Header; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.apache.eventmesh.common.protocol.tcp.RedirectInfo; -import org.apache.eventmesh.common.protocol.tcp.Subscription; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +@Slf4j public class Codec { - private final static Logger logger = LoggerFactory.getLogger(Codec.class); - private static final int FRAME_MAX_LENGTH = 1024 * 1024 * 4; - private static Charset UTF8 = Charset.forName("UTF-8"); + private static final int FRAME_MAX_LENGTH = 1024 * 1024 * 4; + private static final Charset DEFAULT_CHARSET = Charset.forName(Constants.DEFAULT_CHARSET); - private static final byte[] CONSTANT_MAGIC_FLAG = "EventMesh".getBytes(UTF8); + private static final byte[] CONSTANT_MAGIC_FLAG = serializeBytes("EventMesh"); + private static final byte[] VERSION = serializeBytes("0000"); - private static final byte[] VERSION = "0000".getBytes(UTF8); + // todo: move to constants + public static String CLOUD_EVENTS_PROTOCOL_NAME = "cloudevents"; + public static String EM_MESSAGE_PROTOCOL_NAME = "eventmeshmessage"; + public static String OPEN_MESSAGE_PROTOCOL_NAME = "openmessage"; - private static ObjectMapper jsonMapper; + // todo: use json util + private static ObjectMapper OBJECT_MAPPER; static { - jsonMapper = new ObjectMapper(); - jsonMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - jsonMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - jsonMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); - jsonMapper.setTimeZone(TimeZone.getDefault()); + OBJECT_MAPPER = new ObjectMapper(); + OBJECT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); + OBJECT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + OBJECT_MAPPER.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); + OBJECT_MAPPER.setTimeZone(TimeZone.getDefault()); } public static class Encoder extends MessageToByteEncoder { @Override public void encode(ChannelHandlerContext ctx, Package pkg, ByteBuf out) throws Exception { - byte[] headerData; - byte[] bodyData; - - final String headerJson = pkg != null ? jsonMapper.writeValueAsString(pkg.getHeader()) : null; - final String bodyJson = pkg != null ? jsonMapper.writeValueAsString(pkg.getBody()) : null; + Preconditions.checkNotNull(pkg, "TcpPackage cannot be null"); + final Header header = pkg.getHeader(); + Preconditions.checkNotNull(header, "TcpPackage header cannot be null", header); + if (log.isDebugEnabled()) { + log.debug("Encoder pkg={}", JsonUtils.serialize(pkg)); + } - headerData = headerJson == null ? null : headerJson.getBytes(UTF8); - bodyData = bodyJson == null ? null : bodyJson.getBytes(UTF8); + final byte[] headerData = serializeBytes(OBJECT_MAPPER.writeValueAsString(header)); + final byte[] bodyData; - logger.debug("headerJson={}|bodyJson={}", headerJson, bodyJson); + if (StringUtils.equals(CLOUD_EVENTS_PROTOCOL_NAME, header.getStringProperty(Constants.PROTOCOL_TYPE))) { + bodyData = (byte[]) pkg.getBody(); + } else { + bodyData = serializeBytes(OBJECT_MAPPER.writeValueAsString(pkg.getBody())); + } - int headerLength = headerData == null ? 0 : headerData.length; - int bodyLength = bodyData == null ? 0 : bodyData.length; + int headerLength = ArrayUtils.getLength(headerData); + int bodyLength = ArrayUtils.getLength(bodyData); int length = 4 + 4 + headerLength + bodyLength; @@ -89,94 +104,141 @@ public void encode(ChannelHandlerContext ctx, Package pkg, ByteBuf out) throws E out.writeBytes(VERSION); out.writeInt(length); out.writeInt(headerLength); - if (headerData != null) + if (headerData != null) { out.writeBytes(headerData); - if (bodyData != null) + } + if (bodyData != null) { out.writeBytes(bodyData); + } } } - public static class Decoder extends ReplayingDecoder { + public static class Decoder extends ReplayingDecoder { @Override public void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { - Header header = null; - Object body = null; - - int length = 0; - int headerLength = 0; - int bodyLength = 0; - try { - if (null == in) + if (null == in) { return; - - byte[] flagBytes = new byte[CONSTANT_MAGIC_FLAG.length]; - byte[] versionBytes = new byte[VERSION.length]; - - in.readBytes(flagBytes); - in.readBytes(versionBytes); - if (!Arrays.equals(flagBytes, CONSTANT_MAGIC_FLAG) || !Arrays.equals(versionBytes, VERSION)) { - String errorMsg = String.format("invalid magic flag or " + - "version|flag=%s|version=%s|remoteAddress=%s", new String(flagBytes, UTF8), new String - (versionBytes, UTF8), ctx.channel().remoteAddress()); - throw new Exception(errorMsg); - } - - length = in.readInt(); - headerLength = in.readInt(); - bodyLength = length - 8 - headerLength; - byte[] headerData = new byte[headerLength]; - byte[] bodyData = new byte[bodyLength]; - - if (headerLength > 0) { - in.readBytes(headerData); - header = jsonMapper.readValue(new String(headerData, UTF8), Header.class); } - if (bodyLength > 0 && header != null) { - in.readBytes(bodyData); - body = parseFromJson(header.getCommand(), new String(bodyData, UTF8)); - } + byte[] flagBytes = parseFlag(in); + byte[] versionBytes = parseVersion(in); + validateFlag(flagBytes, versionBytes, ctx); - logger.debug("headerJson={}|bodyJson={}", new String(headerData, UTF8), new String(bodyData, UTF8)); + final int length = in.readInt(); + final int headerLength = in.readInt(); + final int bodyLength = length - 8 - headerLength; + Header header = parseHeader(in, headerLength); + Object body = parseBody(in, header, bodyLength); Package pkg = new Package(header, body); out.add(pkg); } catch (Exception e) { - logger.error("decode|length={}|headerLength={}|bodyLength={}|header={}|body={}.", length, - headerLength, bodyLength, header, body); + log.error("decode error| receive: {}.", deserializeBytes(in.array())); throw e; } } + + private byte[] parseFlag(ByteBuf in) { + final byte[] flagBytes = new byte[CONSTANT_MAGIC_FLAG.length]; + in.readBytes(flagBytes); + return flagBytes; + } + + private byte[] parseVersion(ByteBuf in) { + final byte[] versionBytes = new byte[VERSION.length]; + in.readBytes(versionBytes); + return versionBytes; + } + + private Header parseHeader(ByteBuf in, int headerLength) throws JsonProcessingException { + if (headerLength <= 0) { + return null; + } + final byte[] headerData = new byte[headerLength]; + in.readBytes(headerData); + if (log.isDebugEnabled()) { + log.debug("Decode headerJson={}", deserializeBytes(headerData)); + } + return OBJECT_MAPPER.readValue(deserializeBytes(headerData), Header.class); + } + + private Object parseBody(ByteBuf in, Header header, int bodyLength) throws JsonProcessingException { + if (bodyLength <= 0 || header == null) { + return null; + } + final byte[] bodyData = new byte[bodyLength]; + in.readBytes(bodyData); + if (log.isDebugEnabled()) { + log.debug("Decode bodyJson={}", deserializeBytes(bodyData)); + } + return deserializeBody(deserializeBytes(bodyData), header); + } + + private void validateFlag(byte[] flagBytes, byte[] versionBytes, ChannelHandlerContext ctx) { + if (!Arrays.equals(flagBytes, CONSTANT_MAGIC_FLAG) || !Arrays.equals(versionBytes, VERSION)) { + String errorMsg = String.format( + "invalid magic flag or version|flag=%s|version=%s|remoteAddress=%s", + deserializeBytes(flagBytes), deserializeBytes(versionBytes), ctx.channel().remoteAddress()); + throw new IllegalArgumentException(errorMsg); + } + } } - private static Object parseFromJson(Command cmd, String data) throws Exception { - switch (cmd) { + private static Object deserializeBody(String bodyJsonString, Header header) throws JsonProcessingException { + Command command = header.getCmd(); + switch (command) { case HELLO_REQUEST: case RECOMMEND_REQUEST: - return jsonMapper.readValue(data, UserAgent.class); + return OBJECT_MAPPER.readValue(bodyJsonString, UserAgent.class); case SUBSCRIBE_REQUEST: case UNSUBSCRIBE_REQUEST: - return jsonMapper.readValue(data, Subscription.class); + return OBJECT_MAPPER.readValue(bodyJsonString, Subscription.class); case REQUEST_TO_SERVER: case RESPONSE_TO_SERVER: case ASYNC_MESSAGE_TO_SERVER: case BROADCAST_MESSAGE_TO_SERVER: - return jsonMapper.readValue(data, EventMeshMessage.class); case REQUEST_TO_CLIENT: case RESPONSE_TO_CLIENT: case ASYNC_MESSAGE_TO_CLIENT: case BROADCAST_MESSAGE_TO_CLIENT: - return jsonMapper.readValue(data, EventMeshMessage.class); case REQUEST_TO_CLIENT_ACK: case RESPONSE_TO_CLIENT_ACK: case ASYNC_MESSAGE_TO_CLIENT_ACK: case BROADCAST_MESSAGE_TO_CLIENT_ACK: - return jsonMapper.readValue(data, EventMeshMessage.class); + // The message string will be deserialized by protocol plugin, if the event is cloudevents, the body is + // just a string. + return bodyJsonString; case REDIRECT_TO_CLIENT: - return jsonMapper.readValue(data, RedirectInfo.class); + return OBJECT_MAPPER.readValue(bodyJsonString, RedirectInfo.class); default: + log.warn("Invalidate TCP command: {}", command); return null; } } + + /** + * Deserialize bytes to String. + * + * @param bytes + * @return + */ + private static String deserializeBytes(byte[] bytes) { + return new String(bytes, DEFAULT_CHARSET); + } + + /** + * Serialize String to bytes. + * + * @param str + * @return + */ + private static byte[] serializeBytes(String str) { + if (str == null) { + return null; + } + return str.getBytes(DEFAULT_CHARSET); + } + + } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/IPUtil.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/IPUtils.java similarity index 98% rename from eventmesh-common/src/main/java/org/apache/eventmesh/common/IPUtil.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/IPUtils.java index 5165deb8af..434f5a580e 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/IPUtil.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/IPUtils.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.common; +package org.apache.eventmesh.common.utils; import java.net.Inet6Address; import java.net.InetAddress; @@ -30,7 +30,7 @@ import io.netty.channel.Channel; -public class IPUtil { +public class IPUtils { public static String getLocalAddress() { // if the progress works under docker environment diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/RandomStringUtil.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/RandomStringUtils.java similarity index 76% rename from eventmesh-common/src/main/java/org/apache/eventmesh/common/RandomStringUtil.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/RandomStringUtils.java index 802c3a6ccd..aaeaec84a6 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/RandomStringUtil.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/RandomStringUtils.java @@ -15,17 +15,17 @@ * limitations under the License. */ -package org.apache.eventmesh.common; +package org.apache.eventmesh.common.utils; import org.apache.commons.text.RandomStringGenerator; -public class RandomStringUtil { +public class RandomStringUtils { - private final static RandomStringGenerator randomNumGenerator = new RandomStringGenerator.Builder() - .withinRange('0', '9').build(); + private static final RandomStringGenerator RANDOM_NUM_GENERATOR = new RandomStringGenerator.Builder() + .withinRange('0', '9').build(); public static String generateNum(int length) { - return randomNumGenerator.generate(length); + return RANDOM_NUM_GENERATOR.generate(length); } } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadUtil.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/ThreadUtils.java similarity index 70% rename from eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadUtil.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/ThreadUtils.java index 895215d0da..af69f08508 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadUtil.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/ThreadUtils.java @@ -15,13 +15,15 @@ * limitations under the License. */ -package org.apache.eventmesh.common; +package org.apache.eventmesh.common.utils; + +import org.apache.logging.log4j.util.ProcessIdUtil; import java.util.concurrent.ThreadLocalRandom; -public class ThreadUtil { +public class ThreadUtils { - private static long currentPID = -1; + private static volatile long currentPID = -1; public static void randomSleep(int min, int max) throws Exception { // nextInt is normally exclusive of the top value, so add 1 to make it inclusive @@ -35,22 +37,18 @@ public static void randomSleep(int max) throws Exception { } /** - * get current process id only once. + * get current process id. * * @return process id */ public static long getPID() { - if (currentPID >= 0) { - return currentPID; - } - String processName = java.lang.management.ManagementFactory.getRuntimeMXBean().getName(); - if (processName != null && processName.length() > 0) { - try { - currentPID = Long.parseLong(processName.split("@")[0]); - } catch (Exception e) { - return 0; + if (currentPID == -1) { + synchronized (ThreadUtils.class) { + if (currentPID == -1) { + currentPID = Long.parseLong(ProcessIdUtil.getProcessId()); + } } } - return 0; + return currentPID; } } diff --git a/eventmesh-common/src/test/java/org/apache/eventmesh/common/LiteMessageTest.java b/eventmesh-common/src/test/java/org/apache/eventmesh/common/EventMeshMessageTest.java similarity index 69% rename from eventmesh-common/src/test/java/org/apache/eventmesh/common/LiteMessageTest.java rename to eventmesh-common/src/test/java/org/apache/eventmesh/common/EventMeshMessageTest.java index 2f206a8d82..006a1d1cb3 100644 --- a/eventmesh-common/src/test/java/org/apache/eventmesh/common/LiteMessageTest.java +++ b/eventmesh-common/src/test/java/org/apache/eventmesh/common/EventMeshMessageTest.java @@ -17,58 +17,58 @@ package org.apache.eventmesh.common; -import org.junit.Assert; -import org.junit.Test; - import java.util.HashMap; import java.util.Map; -public class LiteMessageTest { +import org.junit.Assert; +import org.junit.Test; + +public class EventMeshMessageTest { @Test public void testGetProp() { - LiteMessage message = createLiteMessage(); + EventMeshMessage message = createLiteMessage(); Assert.assertEquals(2L, message.getProp().size()); } @Test public void testSetProp() { - LiteMessage message = createLiteMessage(); + EventMeshMessage message = createLiteMessage(); Map prop = new HashMap<>(); prop.put("key3", "value3"); message.setProp(prop); Assert.assertEquals(1L, message.getProp().size()); - Assert.assertEquals("value3", message.getPropKey("key3")); + Assert.assertEquals("value3", message.getProp("key3")); } @Test public void testAddProp() { - LiteMessage message = createLiteMessage(); + EventMeshMessage message = createLiteMessage(); message.addProp("key3", "value3"); Assert.assertEquals(3L, message.getProp().size()); - Assert.assertEquals("value1", message.getPropKey("key1")); + Assert.assertEquals("value1", message.getProp("key1")); } @Test public void testGetPropKey() { - LiteMessage message = createLiteMessage(); - Assert.assertEquals("value1", message.getPropKey("key1")); + EventMeshMessage message = createLiteMessage(); + Assert.assertEquals("value1", message.getProp("key1")); } @Test public void testRemoveProp() { - LiteMessage message = createLiteMessage(); - message.removeProp("key1"); + EventMeshMessage message = createLiteMessage(); + message.removePropIfPresent("key1"); Assert.assertEquals(1L, message.getProp().size()); - Assert.assertNull(message.getPropKey("key1")); + Assert.assertNull(message.getProp("key1")); } - private LiteMessage createLiteMessage() { - LiteMessage result = new LiteMessage(); + private EventMeshMessage createLiteMessage() { Map prop = new HashMap<>(); prop.put("key1", "value1"); prop.put("key2", "value2"); - result.setProp(prop); - return result; + return EventMeshMessage.builder() + .prop(prop) + .build(); } } diff --git a/eventmesh-common/src/test/java/org/apache/eventmesh/common/command/HttpCommandTest.java b/eventmesh-common/src/test/java/org/apache/eventmesh/common/protocol/http/HttpCommandTest.java similarity index 86% rename from eventmesh-common/src/test/java/org/apache/eventmesh/common/command/HttpCommandTest.java rename to eventmesh-common/src/test/java/org/apache/eventmesh/common/protocol/http/HttpCommandTest.java index ce5ac0c80b..962d6c7a79 100644 --- a/eventmesh-common/src/test/java/org/apache/eventmesh/common/command/HttpCommandTest.java +++ b/eventmesh-common/src/test/java/org/apache/eventmesh/common/protocol/http/HttpCommandTest.java @@ -15,13 +15,16 @@ * limitations under the License. */ -package org.apache.eventmesh.common.command; +package org.apache.eventmesh.common.protocol.http; + +import static org.mockito.Mockito.when; -import io.netty.handler.codec.http.DefaultFullHttpResponse; -import io.netty.handler.codec.http.HttpHeaderNames; -import org.apache.eventmesh.common.protocol.http.body.BaseResponseBody; import org.apache.eventmesh.common.protocol.http.body.Body; import org.apache.eventmesh.common.protocol.http.header.Header; + +import java.util.HashMap; +import java.util.Map; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -29,11 +32,8 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import java.util.HashMap; -import java.util.Map; - -import static org.hamcrest.CoreMatchers.is; -import static org.mockito.Mockito.when; +import io.netty.handler.codec.http.DefaultFullHttpResponse; +import io.netty.handler.codec.http.HttpHeaderNames; @RunWith(MockitoJUnitRunner.class) public class HttpCommandTest { @@ -63,13 +63,6 @@ public void testCreateHttpCommandResponseWithHeaderAndBody() { Assert.assertEquals("value1", command.getHeader().toMap().get("key1")); } - @Test - public void testCreateHttpCommandResponseWithRetCodeAndRetMsg() { - HttpCommand command = httpCommand.createHttpCommandResponse(200, "SUCCESS"); - Assert.assertThat(((BaseResponseBody) command.getBody()).getRetCode(), is(200)); - Assert.assertEquals("SUCCESS", ((BaseResponseBody) command.getBody()).getRetMsg()); - } - @Test public void testAbstractDesc() { HttpCommand command = httpCommand.createHttpCommandResponse(header, body); diff --git a/eventmesh-common/src/test/java/org/apache/eventmesh/common/IPUtilTest.java b/eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/IPUtilsTest.java similarity index 85% rename from eventmesh-common/src/test/java/org/apache/eventmesh/common/IPUtilTest.java rename to eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/IPUtilsTest.java index d4f4f97139..4adff4475d 100644 --- a/eventmesh-common/src/test/java/org/apache/eventmesh/common/IPUtilTest.java +++ b/eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/IPUtilsTest.java @@ -15,24 +15,24 @@ * limitations under the License. */ -package org.apache.eventmesh.common; +package org.apache.eventmesh.common.utils; import org.junit.Assert; import org.junit.Test; import org.junit.contrib.java.lang.system.EnvironmentVariables; -public class IPUtilTest { +public class IPUtilsTest { @Test public void testDockerIP() { EnvironmentVariables environmentVariables = new EnvironmentVariables(); environmentVariables.set("docker_host_ip", "dockHostIP"); - Assert.assertEquals("dockHostIP", IPUtil.getLocalAddress()); + Assert.assertEquals("dockHostIP", IPUtils.getLocalAddress()); } @Test public void testLocalhostIP() { - Assert.assertNotNull(IPUtil.getLocalAddress()); + Assert.assertNotNull(IPUtils.getLocalAddress()); } } diff --git a/eventmesh-common/src/test/java/org/apache/eventmesh/common/ThreadUtilTest.java b/eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/ThreadUtilsTest.java similarity index 90% rename from eventmesh-common/src/test/java/org/apache/eventmesh/common/ThreadUtilTest.java rename to eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/ThreadUtilsTest.java index b888fde1e8..a9aeb0e38e 100644 --- a/eventmesh-common/src/test/java/org/apache/eventmesh/common/ThreadUtilTest.java +++ b/eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/ThreadUtilsTest.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.common; +package org.apache.eventmesh.common.utils; import org.junit.Assert; import org.junit.Test; -public class ThreadUtilTest { +public class ThreadUtilsTest { @Test public void testRandomSleep() throws InterruptedException { @@ -33,7 +33,7 @@ public void testRandomSleep() throws InterruptedException { @Test public void testPID() { - Assert.assertNotEquals(-1, ThreadUtil.getPID()); + Assert.assertNotEquals(-1, ThreadUtils.getPID()); } class TestThread extends Thread { @@ -47,7 +47,7 @@ public long getSleepTime() { public void run() { long startTime = System.currentTimeMillis(); try { - ThreadUtil.randomSleep(50); + ThreadUtils.randomSleep(50); } catch (Exception ignore) { } sleepTime = System.currentTimeMillis() - startTime; diff --git a/eventmesh-common/src/test/resources/configuration.properties b/eventmesh-common/src/test/resources/configuration.properties index b8bf913d37..a5e0828ca3 100644 --- a/eventmesh-common/src/test/resources/configuration.properties +++ b/eventmesh-common/src/test/resources/configuration.properties @@ -23,4 +23,6 @@ eventMesh.server.name=value5 eventMesh.server.hostIp=value6 eventMesh.connector.plugin.type=rocketmq eventMesh.security.plugin.type=acl -eventMesh.registry.plugin.type=namesrv \ No newline at end of file +eventMesh.registry.plugin.type=namesrv +eventmesh.trace.export.zipkin.ip=localhost +eventmesh.trace.exporter.type=Zipkin \ No newline at end of file diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/build.gradle b/eventmesh-connector-plugin/eventmesh-connector-api/build.gradle index 19cb54c18b..8ccfa87825 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-api/build.gradle +++ b/eventmesh-connector-plugin/eventmesh-connector-api/build.gradle @@ -16,19 +16,18 @@ */ dependencies { - implementation project(":eventmesh-spi") + api project(":eventmesh-spi") implementation project(":eventmesh-common") - api 'io.openmessaging:openmessaging-api' + api 'io.cloudevents:cloudevents-core' api 'io.dropwizard.metrics:metrics-core' api "io.dropwizard.metrics:metrics-healthchecks" api "io.dropwizard.metrics:metrics-annotation" api "io.dropwizard.metrics:metrics-json" - testImplementation project(":eventmesh-spi") - testImplementation project(":eventmesh-common") - testImplementation 'io.openmessaging:openmessaging-api' - testImplementation 'io.dropwizard.metrics:metrics-core' - testImplementation "io.dropwizard.metrics:metrics-healthchecks" - testImplementation "io.dropwizard.metrics:metrics-annotation" - testImplementation "io.dropwizard.metrics:metrics-json" + compileOnly 'org.projectlombok:lombok:1.18.22' + annotationProcessor 'org.projectlombok:lombok:1.18.22' + + testCompileOnly 'org.projectlombok:lombok:1.18.22' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' + } diff --git a/eventmesh-schema-registry/build.gradle b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/AsyncConsumeContext.java similarity index 85% rename from eventmesh-schema-registry/build.gradle rename to eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/AsyncConsumeContext.java index 6a9c064171..7c1c739cd5 100644 --- a/eventmesh-schema-registry/build.gradle +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/AsyncConsumeContext.java @@ -15,3 +15,11 @@ * limitations under the License. */ +package org.apache.eventmesh.api; + + +public abstract class AsyncConsumeContext { + + public abstract void commit(EventMeshAction action); + +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventListener.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventListener.java new file mode 100644 index 0000000000..eede41ca09 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventListener.java @@ -0,0 +1,37 @@ +/* + * Licensed 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.eventmesh.api; + + +import io.cloudevents.CloudEvent; + +/** + * Event listener, registered for consume messages by consumer. + * + *

+ * + * Thread safe requirements: this interface will be invoked by multi threads, + * so users should keep thread safe during the consume process. + * + *

+ */ +public interface EventListener { + + void consume(final CloudEvent cloudEvent, final AsyncConsumeContext context); + +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAction.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAction.java index 4fda6d05b6..f783201086 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAction.java +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAction.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.eventmesh.api; public enum EventMeshAction { diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAsyncConsumeContext.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAsyncConsumeContext.java index c7e4e7fb73..633a5b712b 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAsyncConsumeContext.java +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAsyncConsumeContext.java @@ -14,10 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.eventmesh.api; -import io.openmessaging.api.Action; -import io.openmessaging.api.AsyncConsumeContext; public abstract class EventMeshAsyncConsumeContext extends AsyncConsumeContext { @@ -33,8 +32,4 @@ public void setAbstractContext(AbstractContext abstractContext) { public abstract void commit(EventMeshAction action); - @Override - public void commit(Action action) { - throw new UnsupportedOperationException("not support yet"); - } } \ No newline at end of file diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/LifeCycle.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/LifeCycle.java new file mode 100644 index 0000000000..f5d61de333 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/LifeCycle.java @@ -0,0 +1,36 @@ +/* + * Licensed 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.eventmesh.api; + +import org.apache.eventmesh.api.consumer.Consumer; +import org.apache.eventmesh.api.producer.Producer; + +/** + * The {@code LifeCycle} defines a lifecycle interface for a OMS related service endpoint, + * like {@link Producer}, {@link Consumer}, and so on. + */ +public interface LifeCycle { + + boolean isStarted(); + + boolean isClosed(); + + void start(); + + void shutdown(); +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RRCallback.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RequestReplyCallback.java similarity index 84% rename from eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RRCallback.java rename to eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RequestReplyCallback.java index 788f9f3906..3def887e07 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RRCallback.java +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RequestReplyCallback.java @@ -17,12 +17,11 @@ package org.apache.eventmesh.api; -import io.openmessaging.api.Message; +import io.cloudevents.CloudEvent; -public interface RRCallback { +public interface RequestReplyCallback { - public void onSuccess(Message msg); - - public void onException(Throwable e); + void onSuccess(CloudEvent event); + void onException(Throwable e); } diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendCallback.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendCallback.java new file mode 100644 index 0000000000..c955f5d3aa --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendCallback.java @@ -0,0 +1,33 @@ +/* + * Licensed 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.eventmesh.api; + +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.api.producer.Producer; + +import io.cloudevents.CloudEvent; + +/** + * Call back interface used in {@link Producer#sendAsync(CloudEvent, SendCallback)}. + */ +public interface SendCallback { + + void onSuccess(final SendResult sendResult); + + void onException(final OnExceptionContext context); +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendResult.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendResult.java new file mode 100644 index 0000000000..1a68132c6b --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendResult.java @@ -0,0 +1,45 @@ +/* + * Licensed 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.eventmesh.api; + +public class SendResult { + private String messageId; + + private String topic; + + public String getMessageId() { + return messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + @Override + public String toString() { + return "SendResult[topic=" + topic + ", messageId=" + messageId + ']'; + } +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/MeshMQPushConsumer.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/Consumer.java similarity index 73% rename from eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/MeshMQPushConsumer.java rename to eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/Consumer.java index dcf558b685..87b3ac7bba 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/MeshMQPushConsumer.java +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/Consumer.java @@ -17,28 +17,28 @@ package org.apache.eventmesh.api.consumer; -import java.util.List; -import java.util.Properties; - -import io.openmessaging.api.AsyncMessageListener; -import io.openmessaging.api.Consumer; -import io.openmessaging.api.Message; - import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.api.EventListener; +import org.apache.eventmesh.api.LifeCycle; import org.apache.eventmesh.spi.EventMeshExtensionType; import org.apache.eventmesh.spi.EventMeshSPI; +import java.util.List; +import java.util.Properties; + +import io.cloudevents.CloudEvent; + +/** + * Consumer Interface. + */ @EventMeshSPI(isSingleton = false, eventMeshExtensionType = EventMeshExtensionType.CONNECTOR) -public interface MeshMQPushConsumer extends Consumer { +public interface Consumer extends LifeCycle { void init(Properties keyValue) throws Exception; - void updateOffset(List msgs, AbstractContext context); - -// void registerMessageListener(MessageListenerConcurrently messageListenerConcurrently); + void updateOffset(List cloudEvents, AbstractContext context); - void subscribe(String topic, final AsyncMessageListener listener) throws Exception; + void subscribe(String topic, final EventListener listener) throws Exception; - @Override void unsubscribe(String topic); } diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Schema.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/exception/ConnectorRuntimeException.java similarity index 64% rename from eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Schema.java rename to eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/exception/ConnectorRuntimeException.java index a46b2cd5d3..0efe513652 100644 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Schema.java +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/exception/ConnectorRuntimeException.java @@ -14,30 +14,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.eventmesh.schema.registry.server.domain; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +package org.apache.eventmesh.api.exception; -@Data -@AllArgsConstructor -@NoArgsConstructor -public class Schema { +public class ConnectorRuntimeException extends RuntimeException { - private String id; + public ConnectorRuntimeException() { - private String name; + } - private String comment; + public ConnectorRuntimeException(String message) { + super(message); + } - private String serialization; + public ConnectorRuntimeException(Throwable throwable) { + super(throwable); + } - private String schemaType; + public ConnectorRuntimeException(String message, Throwable throwable) { + super(message, throwable); + } - private String schemaDefinition; - - private String validator; - - private int version; } diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Compatibility.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/exception/OnExceptionContext.java similarity index 77% rename from eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Compatibility.java rename to eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/exception/OnExceptionContext.java index 2e3c829510..d51da7a0d1 100644 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Compatibility.java +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/exception/OnExceptionContext.java @@ -14,15 +14,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.eventmesh.schema.registry.server.domain; + +package org.apache.eventmesh.api.exception; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; @Data -@AllArgsConstructor +@Builder @NoArgsConstructor -public class Compatibility { - private String compatibility; +@AllArgsConstructor +public class OnExceptionContext { + + private String messageId; + + private String topic; + + /** + * Detailed exception stack information. + */ + private ConnectorRuntimeException exception; } diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/factory/ConnectorPluginFactory.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/factory/ConnectorPluginFactory.java index cff0c8edcc..0793634771 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/factory/ConnectorPluginFactory.java +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/factory/ConnectorPluginFactory.java @@ -19,12 +19,12 @@ package org.apache.eventmesh.api.factory; -import org.apache.eventmesh.api.consumer.MeshMQPushConsumer; -import org.apache.eventmesh.api.producer.MeshMQProducer; +import org.apache.eventmesh.api.consumer.Consumer; +import org.apache.eventmesh.api.producer.Producer; import org.apache.eventmesh.spi.EventMeshExtensionFactory; /** - * The factory to get connector {@link MeshMQProducer} and {@link MeshMQPushConsumer} + * The factory to get connector {@link Producer} and {@link Consumer} */ public class ConnectorPluginFactory { @@ -34,8 +34,8 @@ public class ConnectorPluginFactory { * @param connectorPluginName plugin name * @return MeshMQProducer instance */ - public static MeshMQProducer getMeshMQProducer(String connectorPluginName) { - return EventMeshExtensionFactory.getExtension(MeshMQProducer.class, connectorPluginName); + public static Producer getMeshMQProducer(String connectorPluginName) { + return EventMeshExtensionFactory.getExtension(Producer.class, connectorPluginName); } /** @@ -44,8 +44,8 @@ public static MeshMQProducer getMeshMQProducer(String connectorPluginName) { * @param connectorPluginName plugin name * @return MeshMQPushConsumer instance */ - public static MeshMQPushConsumer getMeshMQPushConsumer(String connectorPluginName) { - return EventMeshExtensionFactory.getExtension(MeshMQPushConsumer.class, connectorPluginName); + public static Consumer getMeshMQPushConsumer(String connectorPluginName) { + return EventMeshExtensionFactory.getExtension(Consumer.class, connectorPluginName); } private static T getPlugin(Class pluginType, String pluginName) { diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/MeshMQProducer.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/Producer.java similarity index 61% rename from eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/MeshMQProducer.java rename to eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/Producer.java index d87be7d842..c526215435 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/MeshMQProducer.java +++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/Producer.java @@ -17,29 +17,38 @@ package org.apache.eventmesh.api.producer; -import java.util.Properties; - -import io.openmessaging.api.Message; -import io.openmessaging.api.Producer; -import io.openmessaging.api.SendCallback; - -import org.apache.eventmesh.api.RRCallback; +import org.apache.eventmesh.api.LifeCycle; +import org.apache.eventmesh.api.RequestReplyCallback; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; import org.apache.eventmesh.spi.EventMeshExtensionType; import org.apache.eventmesh.spi.EventMeshSPI; +import java.util.Properties; + +import io.cloudevents.CloudEvent; + +/** + * Producer Interface. + */ @EventMeshSPI(isSingleton = false, eventMeshExtensionType = EventMeshExtensionType.CONNECTOR) -public interface MeshMQProducer extends Producer { +public interface Producer extends LifeCycle { void init(Properties properties) throws Exception; - void send(Message message, SendCallback sendCallback) throws Exception; + SendResult publish(final CloudEvent cloudEvent); + + void publish(CloudEvent cloudEvent, SendCallback sendCallback) throws Exception; + + void sendOneway(final CloudEvent cloudEvent); - void request(Message message, RRCallback rrCallback, long timeout) throws Exception; + void sendAsync(final CloudEvent cloudEvent, final SendCallback sendCallback); - boolean reply(final Message message, final SendCallback sendCallback) throws Exception; + void request(CloudEvent cloudEvent, RequestReplyCallback rrCallback, long timeout) throws Exception; + + boolean reply(final CloudEvent cloudEvent, final SendCallback sendCallback) throws Exception; void checkTopicExist(String topic) throws Exception; void setExtFields(); - } diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/build.gradle b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/build.gradle index eb722cc890..45e6bdd40c 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/build.gradle +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/build.gradle @@ -17,6 +17,7 @@ configurations { implementation.exclude group: 'ch.qos.logback', module: 'logback-classic' + implementation.exclude group: 'log4j', module: 'log4j' } List rocketmq = [ @@ -37,8 +38,8 @@ List rocketmq = [ ] dependencies { - compileOnly project(":eventmesh-common") - compileOnly project(":eventmesh-connector-plugin:eventmesh-connector-api") + implementation project(":eventmesh-common") + implementation project(":eventmesh-connector-plugin:eventmesh-connector-api") implementation rocketmq testImplementation project(":eventmesh-connector-plugin:eventmesh-connector-api") @@ -49,4 +50,10 @@ dependencies { testImplementation "org.powermock:powermock-api-mockito2" testImplementation rocketmq + + compileOnly 'org.projectlombok:lombok:1.18.22' + annotationProcessor 'org.projectlombok:lombok:1.18.22' + + testCompileOnly 'org.projectlombok:lombok:1.18.22' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' } diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java index f1b7ec79f1..06999487d3 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java @@ -1,93 +1,90 @@ -/* - * Licensed 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.eventmesh.connector.rocketmq; - -import java.util.Properties; - -import io.openmessaging.api.Consumer; -import io.openmessaging.api.MessagingAccessPoint; -import io.openmessaging.api.Producer; -import io.openmessaging.api.PullConsumer; -import io.openmessaging.api.batch.BatchConsumer; -import io.openmessaging.api.order.OrderConsumer; -import io.openmessaging.api.order.OrderProducer; -import io.openmessaging.api.transaction.LocalTransactionChecker; -import io.openmessaging.api.transaction.TransactionProducer; - -import org.apache.eventmesh.connector.rocketmq.consumer.PushConsumerImpl; -import org.apache.eventmesh.connector.rocketmq.producer.ProducerImpl; - -public class MessagingAccessPointImpl implements MessagingAccessPoint { - - private Properties accessPointProperties; - - public MessagingAccessPointImpl(final Properties accessPointProperties) { - this.accessPointProperties = accessPointProperties; - } - - @Override - public String version() { - return null; - } - - @Override - public Properties attributes() { - return accessPointProperties; - } - - @Override - public Producer createProducer(Properties properties) { - return new ProducerImpl(this.accessPointProperties); - } - - @Override - public OrderProducer createOrderProducer(Properties properties) { - return null; - } - - @Override - public TransactionProducer createTransactionProducer(Properties properties, LocalTransactionChecker checker) { - return null; - } - - @Override - public TransactionProducer createTransactionProducer(Properties properties) { - return null; - } - - @Override - public Consumer createConsumer(Properties properties) { - return new PushConsumerImpl(properties); - } - - @Override - public PullConsumer createPullConsumer(Properties properties) { - return null; - } - - @Override - public BatchConsumer createBatchConsumer(Properties properties) { - return null; - } - - @Override - public OrderConsumer createOrderedConsumer(Properties properties) { - return null; - } - -} +///* +// * Licensed 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.eventmesh.connector.rocketmq; +// +//import java.util.Properties; +// +//import io.openmessaging.api.Consumer; +//import io.openmessaging.api.MessagingAccessPoint; +//import io.openmessaging.api.Producer; +//import io.openmessaging.api.PullConsumer; +//import io.openmessaging.api.batch.BatchConsumer; +//import io.openmessaging.api.order.OrderConsumer; +//import io.openmessaging.api.order.OrderProducer; +//import io.openmessaging.api.transaction.LocalTransactionChecker; +//import io.openmessaging.api.transaction.TransactionProducer; +// +//public class MessagingAccessPointImpl implements MessagingAccessPoint { +// +// private Properties accessPointProperties; +// +// public MessagingAccessPointImpl(final Properties accessPointProperties) { +// this.accessPointProperties = accessPointProperties; +// } +// +// @Override +// public String version() { +// return null; +// } +// +// @Override +// public Properties attributes() { +// return accessPointProperties; +// } +// +// @Override +// public Producer createProducer(Properties properties) { +// return null; +// } +// +// @Override +// public OrderProducer createOrderProducer(Properties properties) { +// return null; +// } +// +// @Override +// public TransactionProducer createTransactionProducer(Properties properties, LocalTransactionChecker checker) { +// return null; +// } +// +// @Override +// public TransactionProducer createTransactionProducer(Properties properties) { +// return null; +// } +// +// @Override +// public Consumer createConsumer(Properties properties) { +// return null; +// } +// +// @Override +// public PullConsumer createPullConsumer(Properties properties) { +// return null; +// } +// +// @Override +// public BatchConsumer createBatchConsumer(Properties properties) { +// return null; +// } +// +// @Override +// public OrderConsumer createOrderedConsumer(Properties properties) { +// return null; +// } +// +//} diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/admin/command/Command.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/admin/command/Command.java new file mode 100644 index 0000000000..9f3b5e9e60 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/admin/command/Command.java @@ -0,0 +1,52 @@ +/* + * Licensed 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.eventmesh.connector.rocketmq.admin.command; + +import org.apache.eventmesh.connector.rocketmq.config.ClientConfiguration; + +import org.apache.rocketmq.acl.common.AclClientRPCHook; +import org.apache.rocketmq.acl.common.SessionCredentials; +import org.apache.rocketmq.remoting.RPCHook; +import org.apache.rocketmq.tools.admin.DefaultMQAdminExt; + +import java.util.UUID; + +public abstract class Command { + protected DefaultMQAdminExt adminExt; + + protected String nameServerAddr; + protected String clusterName; + + public void init() { + final ClientConfiguration clientConfiguration = new ClientConfiguration(); + clientConfiguration.init(); + + nameServerAddr = clientConfiguration.namesrvAddr; + clusterName = clientConfiguration.clusterName; + String accessKey = clientConfiguration.accessKey; + String secretKey = clientConfiguration.secretKey; + + RPCHook rpcHook = new AclClientRPCHook(new SessionCredentials(accessKey, secretKey)); + adminExt = new DefaultMQAdminExt(rpcHook); + String groupId = UUID.randomUUID().toString(); + adminExt.setAdminExtGroup("admin_ext_group-" + groupId); + adminExt.setNamesrvAddr(nameServerAddr); + } + + public abstract void execute() throws Exception; +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/admin/command/CreateTopicCommand.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/admin/command/CreateTopicCommand.java new file mode 100644 index 0000000000..53f1822560 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/admin/command/CreateTopicCommand.java @@ -0,0 +1,84 @@ +/* + * Licensed 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.eventmesh.connector.rocketmq.admin.command; + +import org.apache.commons.lang3.StringUtils; +import org.apache.rocketmq.common.TopicConfig; +import org.apache.rocketmq.tools.command.CommandUtil; + +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CreateTopicCommand extends Command { + public Logger logger = LoggerFactory.getLogger(this.getClass()); + + private int numOfQueue = 4; + private int queuePermission = 6; + private String topicName = ""; + + @Override + public void execute() throws Exception { + if (StringUtils.isBlank(topicName)) { + logger.error("Topic name can not be blank."); + throw new Exception("Topic name can not be blank."); + } + try { + init(); + adminExt.start(); + Set brokersAddr = CommandUtil.fetchMasterAddrByClusterName( + adminExt, clusterName); + for (String masterAddr : brokersAddr) { + TopicConfig topicConfig = new TopicConfig(); + topicConfig.setTopicName(topicName); + topicConfig.setReadQueueNums(numOfQueue); + topicConfig.setWriteQueueNums(numOfQueue); + topicConfig.setPerm(queuePermission); + adminExt.createAndUpdateTopicConfig(masterAddr, topicConfig); + logger.info("Topic {} is created for RocketMQ broker {}", topicName, masterAddr); + } + } finally { + adminExt.shutdown(); + } + } + + public int getNumOfQueue() { + return numOfQueue; + } + + public int getQueuePermission() { + return queuePermission; + } + + public String getTopicName() { + return topicName; + } + + public void setTopicName(String topicName) { + this.topicName = topicName; + } + + public void setNumOfQueue(int numOfQueue) { + this.numOfQueue = numOfQueue; + } + + public void setQueuePermission(int permission) { + this.queuePermission = permission; + } +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/RocketMQMessageFactory.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/RocketMQMessageFactory.java new file mode 100644 index 0000000000..966be12844 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/RocketMQMessageFactory.java @@ -0,0 +1,79 @@ +/* + * Licensed 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.eventmesh.connector.rocketmq.cloudevent; + +import org.apache.rocketmq.common.message.Message; + +import java.util.Map; + +import javax.annotation.ParametersAreNonnullByDefault; + +import io.cloudevents.core.message.MessageReader; +import io.cloudevents.core.message.MessageWriter; +import io.cloudevents.core.message.impl.GenericStructuredMessageReader; +import io.cloudevents.core.message.impl.MessageUtils; +import io.cloudevents.lang.Nullable; +import io.cloudevents.rw.CloudEventRWException; +import io.cloudevents.rw.CloudEventWriter; + +import org.apache.eventmesh.connector.rocketmq.cloudevent.impl.RocketMQBinaryMessageReader; +import org.apache.eventmesh.connector.rocketmq.cloudevent.impl.RocketMQHeaders; +import org.apache.eventmesh.connector.rocketmq.cloudevent.impl.RocketMQMessageWriter; + + +@ParametersAreNonnullByDefault +public final class RocketMQMessageFactory { + + private RocketMQMessageFactory() { + // prevent instantiation + } + + public static MessageReader createReader(final Message message) throws CloudEventRWException { + return createReader(message.getProperties(), message.getBody()); + } + + + public static MessageReader createReader(final Map props, + @Nullable final byte[] body) + throws CloudEventRWException { + + return MessageUtils.parseStructuredOrBinaryMessage( + () -> null, + format -> null, + () -> props.get(RocketMQHeaders.SPEC_VERSION), + sv -> new RocketMQBinaryMessageReader(sv, props, body) + ); + } + + + public static MessageWriter, Message> createWriter(String topic) { + return new RocketMQMessageWriter<>(topic); + } + + public static MessageWriter, Message> createWriter(String topic, + String keys) { + return new RocketMQMessageWriter<>(topic, keys); + } + + public static MessageWriter, Message> createWriter(String topic, + String keys, + String tags) { + return new RocketMQMessageWriter<>(topic, keys, tags); + } + +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQBinaryMessageReader.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQBinaryMessageReader.java new file mode 100644 index 0000000000..8b120380b5 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQBinaryMessageReader.java @@ -0,0 +1,69 @@ +/* + * Licensed 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.eventmesh.connector.rocketmq.cloudevent.impl; + +import java.util.Map; +import java.util.Objects; +import java.util.function.BiConsumer; + +import io.cloudevents.SpecVersion; +import io.cloudevents.core.data.BytesCloudEventData; +import io.cloudevents.core.message.impl.BaseGenericBinaryMessageReaderImpl; + +public class RocketMQBinaryMessageReader + extends BaseGenericBinaryMessageReaderImpl { + + private final Map headers; + + public RocketMQBinaryMessageReader(SpecVersion version, Map headers, + byte[] payload) { + super(version, + payload != null && payload.length > 0 ? BytesCloudEventData.wrap(payload) : null); + + Objects.requireNonNull(headers); + this.headers = headers; + } + + @Override + protected boolean isContentTypeHeader(String key) { + return key.equals(RocketMQHeaders.CONTENT_TYPE); + } + + @Override + protected boolean isCloudEventsHeader(String key) { + // return key.length() > 3 && key.substring(0, RocketMQHeaders.CE_PREFIX.length()) + //.startsWith(RocketMQHeaders.CE_PREFIX); + return true; + } + + @Override + protected String toCloudEventsKey(String key) { + //return key.substring(RocketMQHeaders.CE_PREFIX.length()).toLowerCase(); + return key.toLowerCase(); + } + + @Override + protected void forEachHeader(BiConsumer fn) { + this.headers.forEach((k, v) -> fn.accept(k, v)); + } + + @Override + protected String toCloudEventsValue(String value) { + return value; + } +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQHeaders.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQHeaders.java new file mode 100644 index 0000000000..64600ae0a7 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQHeaders.java @@ -0,0 +1,39 @@ +/* + * Licensed 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.eventmesh.connector.rocketmq.cloudevent.impl; + +import java.util.Map; + +import io.cloudevents.core.message.impl.MessageUtils; +import io.cloudevents.core.v1.CloudEventV1; + +public class RocketMQHeaders { + + public static final String CE_PREFIX = "CE_"; + + protected static final Map ATTRIBUTES_TO_HEADERS = + MessageUtils.generateAttributesToHeadersMapping(v -> v); + + public static final String CONTENT_TYPE = + ATTRIBUTES_TO_HEADERS.get(CloudEventV1.DATACONTENTTYPE); + + public static final String SPEC_VERSION = ATTRIBUTES_TO_HEADERS.get(CloudEventV1.SPECVERSION); + + +} + diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQMessageWriter.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQMessageWriter.java new file mode 100644 index 0000000000..60f0609a36 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQMessageWriter.java @@ -0,0 +1,105 @@ +/* + * Licensed 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.eventmesh.connector.rocketmq.cloudevent.impl; + +import org.apache.rocketmq.common.message.Message; + +import io.cloudevents.CloudEventData; +import io.cloudevents.SpecVersion; +import io.cloudevents.core.format.EventFormat; +import io.cloudevents.core.message.MessageWriter; +import io.cloudevents.rw.CloudEventContextWriter; +import io.cloudevents.rw.CloudEventRWException; +import io.cloudevents.rw.CloudEventWriter; + + +public final class RocketMQMessageWriter + implements MessageWriter, Message>, CloudEventWriter { + + private Message message; + + + public RocketMQMessageWriter(String topic) { + message = new Message(); + message.setTopic(topic); + } + + public RocketMQMessageWriter(String topic, String keys) { + message = new Message(); + + message.setTopic(topic); + + if (keys != null && keys.length() > 0) { + message.setKeys(keys); + } + } + + public RocketMQMessageWriter(String topic, String keys, String tags) { + message = new Message(); + + message.setTopic(topic); + + if (tags != null && tags.length() > 0) { + message.setTags(tags); + } + + if (keys != null && keys.length() > 0) { + message.setKeys(keys); + } + } + + + @Override + public CloudEventContextWriter withContextAttribute(String name, String value) + throws CloudEventRWException { + + //String propName = RocketMQHeaders.ATTRIBUTES_TO_HEADERS.get(name); + //if (propName == null) { + //propName = RocketMQHeaders.CE_PREFIX + name; + //} + //message.putUserProperty(propName, value); + message.putUserProperty(name, value); + return this; + } + + @Override + public RocketMQMessageWriter create(final SpecVersion version) { + message.putUserProperty(RocketMQHeaders.SPEC_VERSION, version.toString()); + return this; + } + + @Override + public Message setEvent(final EventFormat format, final byte[] value) + throws CloudEventRWException { + message.putUserProperty(RocketMQHeaders.CONTENT_TYPE, format.serializedContentType()); + message.setBody(value); + return message; + } + + @Override + public Message end(final CloudEventData data) throws CloudEventRWException { + message.setBody(data.toBytes()); + return message; + } + + @Override + public Message end() { + message.setBody(null); + return message; + } +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/EventMeshConstants.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/EventMeshConstants.java index 69fb8c10dc..c815df9730 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/EventMeshConstants.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/EventMeshConstants.java @@ -69,33 +69,33 @@ public class EventMeshConstants { public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; - public static final String BORN_TIMESTAMP = "BORN_TIME"; - public static final String STORE_TIMESTAMP = "STORE_TIME"; - public static final String LEAVE_TIMESTAMP = "LEAVE_TIME"; - public static final String ARRIVE_TIMESTAMP = "ARRIVE_TIME"; + public static final String BORN_TIMESTAMP = "borntime"; + public static final String STORE_TIMESTAMP = "storetime"; + public static final String LEAVE_TIMESTAMP = "leavetime"; + public static final String ARRIVE_TIMESTAMP = "arrivetime"; public static final String KEYS_UPPERCASE = "KEYS"; public static final String KEYS_LOWERCASE = "keys"; public static final String RR_REQUEST_UNIQ_ID = "RR_REQUEST_UNIQ_ID"; - public static final String TTL = "TTL"; + public static final String TTL = "ttl"; - public static final String TAG = "TAG"; + public static final String TAG = "tag"; - public static final String MANAGE_SUBSYSTEM = "subSystem"; + public static final String MANAGE_SUBSYSTEM = "subsystem"; public static final String MANAGE_IP = "ip"; public static final String MANAGE_PORT = "port"; - public static final String MANAGE_DEST_IP = "destEventMeshIp"; - public static final String MANAGE_DEST_PORT = "destEventMeshPort"; + public static final String MANAGE_DEST_IP = "desteventmeship"; + public static final String MANAGE_DEST_PORT = "desteventmeshport"; public static final String MANAGE_PATH = "path"; public static final String MANAGE_GROUP = "group"; public static final String MANAGE_PURPOSE = "purpose"; public static final String MANAGE_TOPIC = "topic"; - public static final String EventMesh_SEND_BACK_TIMES = "EventMeshSendBackTimes"; + public static final String EventMesh_SEND_BACK_TIMES = "eventmeshsendbacktimes"; - public static final String EventMesh_SEND_BACK_IP = "EventMeshSendBackIp"; + public static final String EventMesh_SEND_BACK_IP = "eventmeshsendbackip"; - public static final String EventMesh_REGISTRY_ADDR_KEY = "EventMeshRegistryAddr"; + public static final String EventMesh_REGISTRY_ADDR_KEY = "eventmeshregistryaddr"; public static int DEFAULT_TIME_OUT_MILLS = 5 * 1000; diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfig.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfig.java index aad0b49a53..f03a38a4a9 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfig.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfig.java @@ -17,11 +17,10 @@ package org.apache.eventmesh.connector.rocketmq.config; -import io.openmessaging.api.OMSBuiltinKeys; import org.apache.eventmesh.connector.rocketmq.domain.NonStandardKeys; -public class ClientConfig implements OMSBuiltinKeys, NonStandardKeys { +public class ClientConfig implements NonStandardKeys { private String driverImpl; private String accessPoints; private String namespace; diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfiguration.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfiguration.java index f1b9335bbe..20e6d87b61 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfiguration.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfiguration.java @@ -17,107 +17,140 @@ package org.apache.eventmesh.connector.rocketmq.config; -import com.google.common.base.Preconditions; - import org.apache.commons.lang3.StringUtils; +import com.google.common.base.Preconditions; + public class ClientConfiguration { - public String namesrvAddr = ""; - public String clientUserName = "username"; - public String clientPass = "password"; - public Integer consumeThreadMin = 2; - public Integer consumeThreadMax = 2; - public Integer consumeQueueSize = 10000; - public Integer pullBatchSize = 32; - public Integer ackWindow = 1000; - public Integer pubWindow = 100; - public long consumeTimeout = 0L; - public Integer pollNameServerInterval = 10 * 1000; + public String namesrvAddr = ""; + public String clientUserName = "username"; + public String clientPass = "password"; + public Integer consumeThreadMin = 2; + public Integer consumeThreadMax = 2; + public Integer consumeQueueSize = 10000; + public Integer pullBatchSize = 32; + public Integer ackWindow = 1000; + public Integer pubWindow = 100; + public long consumeTimeout = 0L; + public Integer pollNameServerInterval = 10 * 1000; public Integer heartbeatBrokerInterval = 30 * 1000; - public Integer rebalanceInterval = 20 * 1000; - - protected ConfigurationWrapper configurationWrapper; - - public ClientConfiguration(ConfigurationWrapper configurationWrapper) { - this.configurationWrapper = configurationWrapper; - } + public Integer rebalanceInterval = 20 * 1000; + public String clusterName = ""; + public String accessKey = ""; + public String secretKey = ""; public void init() { - String clientUserNameStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_USERNAME); + String clientUserNameStr = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_USERNAME); if (StringUtils.isNotBlank(clientUserNameStr)) { clientUserName = StringUtils.trim(clientUserNameStr); } - String clientPassStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_PASSWORD); + String clientPassStr = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_PASSWORD); if (StringUtils.isNotBlank(clientPassStr)) { clientPass = StringUtils.trim(clientPassStr); } - String namesrvAddrStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_NAMESRV_ADDR); - Preconditions.checkState(StringUtils.isNotEmpty(namesrvAddrStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_NAMESRV_ADDR)); + String namesrvAddrStr = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_NAMESRV_ADDR); + Preconditions.checkState(StringUtils.isNotEmpty(namesrvAddrStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_NAMESRV_ADDR)); namesrvAddr = StringUtils.trim(namesrvAddrStr); - String consumeThreadPoolMinStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN); + String consumeThreadPoolMinStr = + ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN); if (StringUtils.isNotEmpty(consumeThreadPoolMinStr)) { - Preconditions.checkState(StringUtils.isNumeric(consumeThreadPoolMinStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN)); + Preconditions.checkState(StringUtils.isNumeric(consumeThreadPoolMinStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN)); consumeThreadMin = Integer.valueOf(consumeThreadPoolMinStr); } - String consumeThreadPoolMaxStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX); + String consumeThreadPoolMaxStr = + ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX); if (StringUtils.isNotEmpty(consumeThreadPoolMaxStr)) { - Preconditions.checkState(StringUtils.isNumeric(consumeThreadPoolMaxStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX)); + Preconditions.checkState(StringUtils.isNumeric(consumeThreadPoolMaxStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX)); consumeThreadMax = Integer.valueOf(consumeThreadPoolMaxStr); } - String consumerThreadPoolQueueSizeStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE); + String consumerThreadPoolQueueSizeStr = + ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE); if (StringUtils.isNotEmpty(consumerThreadPoolQueueSizeStr)) { - Preconditions.checkState(StringUtils.isNumeric(consumerThreadPoolQueueSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE)); + Preconditions.checkState(StringUtils.isNumeric(consumerThreadPoolQueueSizeStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE)); consumeQueueSize = Integer.valueOf(consumerThreadPoolQueueSizeStr); } - String clientAckWindowStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_ACK_WINDOW); + String clientAckWindowStr = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_ACK_WINDOW); if (StringUtils.isNotEmpty(clientAckWindowStr)) { - Preconditions.checkState(StringUtils.isNumeric(clientAckWindowStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_ACK_WINDOW)); + Preconditions.checkState(StringUtils.isNumeric(clientAckWindowStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_ACK_WINDOW)); ackWindow = Integer.valueOf(clientAckWindowStr); } - String clientPubWindowStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PUB_WINDOW); + String clientPubWindowStr = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PUB_WINDOW); if (StringUtils.isNotEmpty(clientPubWindowStr)) { - Preconditions.checkState(StringUtils.isNumeric(clientPubWindowStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PUB_WINDOW)); + Preconditions.checkState(StringUtils.isNumeric(clientPubWindowStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PUB_WINDOW)); pubWindow = Integer.valueOf(clientPubWindowStr); } - String consumeTimeoutStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT); + String consumeTimeoutStr = + ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT); if (StringUtils.isNotBlank(consumeTimeoutStr)) { - Preconditions.checkState(StringUtils.isNumeric(consumeTimeoutStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT)); + Preconditions.checkState(StringUtils.isNumeric(consumeTimeoutStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT)); consumeTimeout = Long.valueOf(consumeTimeoutStr); } - String clientPullBatchSizeStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE); + String clientPullBatchSizeStr = + ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE); if (StringUtils.isNotEmpty(clientPullBatchSizeStr)) { - Preconditions.checkState(StringUtils.isNumeric(clientPullBatchSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE)); + Preconditions.checkState(StringUtils.isNumeric(clientPullBatchSizeStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE)); pullBatchSize = Integer.valueOf(clientPullBatchSizeStr); } - String clientPollNamesrvIntervalStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL); + String clientPollNamesrvIntervalStr = + ConfigurationWrapper.getProp( + ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL); if (StringUtils.isNotEmpty(clientPollNamesrvIntervalStr)) { - Preconditions.checkState(StringUtils.isNumeric(clientPollNamesrvIntervalStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL)); + Preconditions.checkState(StringUtils.isNumeric(clientPollNamesrvIntervalStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL)); pollNameServerInterval = Integer.valueOf(clientPollNamesrvIntervalStr); } - String clientHeartbeatBrokerIntervalStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVAL); + String clientHeartbeatBrokerIntervalStr = + ConfigurationWrapper.getProp( + ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVAL); if (StringUtils.isNotEmpty(clientHeartbeatBrokerIntervalStr)) { - Preconditions.checkState(StringUtils.isNumeric(clientHeartbeatBrokerIntervalStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVAL)); + Preconditions.checkState(StringUtils.isNumeric(clientHeartbeatBrokerIntervalStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVAL)); heartbeatBrokerInterval = Integer.valueOf(clientHeartbeatBrokerIntervalStr); } - String clientRebalanceIntervalIntervalStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVAL); + String clientRebalanceIntervalIntervalStr = + ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVAL); if (StringUtils.isNotEmpty(clientRebalanceIntervalIntervalStr)) { - Preconditions.checkState(StringUtils.isNumeric(clientRebalanceIntervalIntervalStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVAL)); + Preconditions.checkState(StringUtils.isNumeric(clientRebalanceIntervalIntervalStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVAL)); rebalanceInterval = Integer.valueOf(clientRebalanceIntervalIntervalStr); } + + String cluster = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLUSTER); + if (StringUtils.isNotBlank(cluster)) { + clusterName = cluster; + } + + String ak = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_ACCESS_KEY); + if (StringUtils.isNotBlank(ak)) { + accessKey = ak; + } + + String sk = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_SECRET_KEY); + if (StringUtils.isNotBlank(sk)) { + secretKey = sk; + } } static class ConfKeys { @@ -128,25 +161,41 @@ static class ConfKeys { public static String KEYS_EVENTMESH_ROCKETMQ_PASSWORD = "eventMesh.server.rocketmq.password"; - public static String KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN = "eventMesh.server.rocketmq.client.consumeThreadMin"; + public static String KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN = + "eventMesh.server.rocketmq.client.consumeThreadMin"; - public static String KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX = "eventMesh.server.rocketmq.client.consumeThreadMax"; + public static String KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX = + "eventMesh.server.rocketmq.client.consumeThreadMax"; - public static String KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE = "eventMesh.server.rocketmq.client.consumeThreadPoolQueueSize"; + public static String KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE = + "eventMesh.server.rocketmq.client.consumeThreadPoolQueueSize"; public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_ACK_WINDOW = "eventMesh.server.rocketmq.client.ackwindow"; public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_PUB_WINDOW = "eventMesh.server.rocketmq.client.pubwindow"; - public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT = "eventMesh.server.rocketmq.client.comsumeTimeoutInMin"; + public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT = + "eventMesh.server.rocketmq.client.comsumeTimeoutInMin"; + + public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE = + "eventMesh.server.rocketmq.client.pullBatchSize"; + + public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL = + "eventMesh.server.rocketmq.client.pollNameServerInterval"; + + public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVAL = + "eventMesh.server.rocketmq.client.heartbeatBrokerInterval"; - public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE = "eventMesh.server.rocketmq.client.pullBatchSize"; + public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVAL = + "eventMesh.server.rocketmq.client.rebalanceInterval"; - public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL = "eventMesh.server.rocketmq.client.pollNameServerInterval"; + public static String KEYS_EVENTMESH_ROCKETMQ_CLUSTER = "eventMesh.server.rocketmq.cluster"; - public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVAL = "eventMesh.server.rocketmq.client.heartbeatBrokerInterval"; + public static String KEYS_EVENTMESH_ROCKETMQ_ACCESS_KEY = + "eventMesh.server.rocketmq.accessKey"; - public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVAL = "eventMesh.server.rocketmq.client.rebalanceInterval"; + public static String KEYS_EVENTMESH_ROCKETMQ_SECRET_KEY = + "eventMesh.server.rocketmq.secretKey"; } } \ No newline at end of file diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWrapper.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWrapper.java index 9334b5fc98..9ff3861ad6 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWrapper.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWrapper.java @@ -17,60 +17,48 @@ package org.apache.eventmesh.connector.rocketmq.config; +import org.apache.eventmesh.connector.rocketmq.common.EventMeshConstants; + +import org.apache.commons.lang3.StringUtils; + import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.net.URL; import java.util.Properties; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.common.ThreadPoolFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.experimental.UtilityClass; +import lombok.extern.slf4j.Slf4j; +@Slf4j +@UtilityClass public class ConfigurationWrapper { - public Logger logger = LoggerFactory.getLogger(this.getClass()); - - private String file; - - private Properties properties = new Properties(); - - private boolean reload = true; - - private ScheduledExecutorService configLoader = ThreadPoolFactory.createSingleScheduledExecutor("eventMesh-configloader-"); + private static final Properties properties = new Properties(); - public ConfigurationWrapper(String file, boolean reload) { - this.file = file; - this.reload = reload; - init(); - } - - private void init() { - load(); - if (this.reload) { - configLoader.scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - load(); - } - }, 30 * 1000, 30 * 1000, TimeUnit.MILLISECONDS); - } - } - - private void load() { + static { + String configFile = getConfigFilePath(); + log.info("loading config: {}", configFile); try { - logger.info("loading config: {}", file); - properties.load(new BufferedReader(new FileReader( - new File(file)))); + properties.load(new BufferedReader(new FileReader(configFile))); } catch (IOException e) { - logger.error("loading properties [{}] error", file, e); + throw new IllegalArgumentException( + String.format("Cannot load RocketMQ configuration file from :%s", configFile)); } } public String getProp(String key) { return StringUtils.isEmpty(key) ? null : properties.getProperty(key, null); } + + private static String getConfigFilePath() { + // get from classpath + URL resource = ConfigurationWrapper.class.getClassLoader().getResource(EventMeshConstants.EVENTMESH_CONF_FILE); + if (resource != null && new File(resource.getPath()).exists()) { + return resource.getPath(); + } + // get from config home + return EventMeshConstants.EVENTMESH_CONF_HOME + File.separator + EventMeshConstants.EVENTMESH_CONF_FILE; + } } diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java index 47565e3b03..e7e5ae8e7e 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java @@ -17,21 +17,14 @@ package org.apache.eventmesh.connector.rocketmq.consumer; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; -import io.openmessaging.api.AsyncGenericMessageListener; -import io.openmessaging.api.AsyncMessageListener; -import io.openmessaging.api.Consumer; -import io.openmessaging.api.GenericMessageListener; -import io.openmessaging.api.Message; -import io.openmessaging.api.MessageListener; -import io.openmessaging.api.MessageSelector; -import io.openmessaging.api.exception.OMSRuntimeException; +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.api.AsyncConsumeContext; +import org.apache.eventmesh.api.EventListener; import org.apache.eventmesh.api.EventMeshAction; import org.apache.eventmesh.api.EventMeshAsyncConsumeContext; +import org.apache.eventmesh.api.exception.ConnectorRuntimeException; import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.connector.rocketmq.cloudevent.RocketMQMessageFactory; import org.apache.eventmesh.connector.rocketmq.common.EventMeshConstants; import org.apache.eventmesh.connector.rocketmq.config.ClientConfig; import org.apache.eventmesh.connector.rocketmq.domain.NonStandardKeys; @@ -40,17 +33,34 @@ import org.apache.eventmesh.connector.rocketmq.patch.EventMeshMessageListenerConcurrently; import org.apache.eventmesh.connector.rocketmq.utils.BeanUtils; import org.apache.eventmesh.connector.rocketmq.utils.OMSUtil; +import org.apache.eventmesh.connector.rocketmq.utils.CloudEventUtils; + +import org.apache.commons.lang3.StringUtils; import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.impl.consumer.ConsumeMessageConcurrentlyService; +import org.apache.rocketmq.client.impl.consumer.ConsumeMessageService; +import org.apache.rocketmq.client.utils.MessageUtil; +import org.apache.rocketmq.common.message.MessageConst; import org.apache.rocketmq.common.message.MessageExt; import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; import org.apache.rocketmq.remoting.protocol.LanguageCode; -public class PushConsumerImpl implements Consumer { +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; + +public class PushConsumerImpl { private final DefaultMQPushConsumer rocketmqPushConsumer; private final Properties properties; private AtomicBoolean started = new AtomicBoolean(false); - private final Map subscribeTable = new ConcurrentHashMap<>(); + private final Map subscribeTable = new ConcurrentHashMap<>(); private final ClientConfig clientConfig; public PushConsumerImpl(final Properties properties) { @@ -58,25 +68,23 @@ public PushConsumerImpl(final Properties properties) { this.properties = properties; this.clientConfig = BeanUtils.populate(properties, ClientConfig.class); -// if ("true".equalsIgnoreCase(System.getenv("OMS_RMQ_DIRECT_NAME_SRV"))) { -// -// -// } String accessPoints = clientConfig.getAccessPoints(); if (accessPoints == null || accessPoints.isEmpty()) { - throw new OMSRuntimeException(-1, "OMS AccessPoints is null or empty."); + throw new ConnectorRuntimeException("OMS AccessPoints is null or empty."); } this.rocketmqPushConsumer.setNamesrvAddr(accessPoints.replace(',', ';')); String consumerGroup = clientConfig.getConsumerId(); if (null == consumerGroup || consumerGroup.isEmpty()) { - throw new OMSRuntimeException(-1, "Consumer Group is necessary for RocketMQ, please set it."); + throw new ConnectorRuntimeException( + "Consumer Group is necessary for RocketMQ, please set it."); } this.rocketmqPushConsumer.setConsumerGroup(consumerGroup); this.rocketmqPushConsumer.setMaxReconsumeTimes(clientConfig.getRmqMaxRedeliveryTimes()); this.rocketmqPushConsumer.setConsumeTimeout(clientConfig.getRmqMessageConsumeTimeout()); this.rocketmqPushConsumer.setConsumeThreadMax(clientConfig.getRmqMaxConsumeThreadNums()); this.rocketmqPushConsumer.setConsumeThreadMin(clientConfig.getRmqMinConsumeThreadNums()); - this.rocketmqPushConsumer.setMessageModel(MessageModel.valueOf(clientConfig.getMessageModel())); + this.rocketmqPushConsumer.setMessageModel( + MessageModel.valueOf(clientConfig.getMessageModel())); String consumerId = OMSUtil.buildInstanceName(); //this.rocketmqPushConsumer.setInstanceName(consumerId); @@ -85,109 +93,9 @@ public PushConsumerImpl(final Properties properties) { this.rocketmqPushConsumer.setLanguage(LanguageCode.OMS); if (clientConfig.getMessageModel().equalsIgnoreCase(MessageModel.BROADCASTING.name())) { - rocketmqPushConsumer.registerMessageListener(new EventMeshMessageListenerConcurrently() { - - @Override - public EventMeshConsumeConcurrentlyStatus handleMessage(MessageExt msg, EventMeshConsumeConcurrentlyContext context) { - if (msg == null) { - return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS; - } - - -// if (!EventMeshUtil.isValidRMBTopic(msg.getTopic())) { -// return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS; -// } - - msg.putUserProperty(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP, String.valueOf(msg.getBornTimestamp())); - msg.putUserProperty(Constants.PROPERTY_MESSAGE_STORE_TIMESTAMP, String.valueOf(msg.getStoreTimestamp())); - - Message omsMsg = OMSUtil.msgConvert(msg); - - AsyncMessageListener listener = PushConsumerImpl.this.subscribeTable.get(msg.getTopic()); - - if (listener == null) { - throw new OMSRuntimeException(-1, - String.format("The topic/queue %s isn't attached to this consumer", msg.getTopic())); - } - - final Properties contextProperties = new Properties(); - contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name()); - EventMeshAsyncConsumeContext omsContext = new EventMeshAsyncConsumeContext() { - @Override - public void commit(EventMeshAction action) { - switch (action){ - case CommitMessage: - contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS.name()); - break; - case ReconsumeLater: - contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name()); - break; - case ManualAck: - contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.CONSUME_FINISH.name()); - break; - default: - break; - } - } - }; - omsContext.setAbstractContext(context); - listener.consume(omsMsg, omsContext); - - return EventMeshConsumeConcurrentlyStatus.valueOf(contextProperties.getProperty(NonStandardKeys.MESSAGE_CONSUME_STATUS)); - } - }); + rocketmqPushConsumer.registerMessageListener(new BroadCastingMessageListener()); } else { - rocketmqPushConsumer.registerMessageListener(new EventMeshMessageListenerConcurrently() { - - @Override - public EventMeshConsumeConcurrentlyStatus handleMessage(MessageExt msg, EventMeshConsumeConcurrentlyContext context) { - if (msg == null) { - return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS; - } -// if (!EventMeshUtil.isValidRMBTopic(msg.getTopic())) { -// return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS; -// } - - msg.putUserProperty(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP, String.valueOf(msg.getBornTimestamp())); - msg.putUserProperty(EventMeshConstants.STORE_TIMESTAMP, String.valueOf(msg.getStoreTimestamp())); - - Message omsMsg = OMSUtil.msgConvert(msg); - - AsyncMessageListener listener = PushConsumerImpl.this.subscribeTable.get(msg.getTopic()); - - if (listener == null) { - throw new OMSRuntimeException(-1, - String.format("The topic/queue %s isn't attached to this consumer", msg.getTopic())); - } - - final Properties contextProperties = new Properties(); - - contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name()); - - EventMeshAsyncConsumeContext omsContext = new EventMeshAsyncConsumeContext() { - @Override - public void commit(EventMeshAction action) { - switch (action) { - case CommitMessage: - contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS.name()); - break; - case ReconsumeLater: - contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name()); - break; - case ManualAck: - contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.CONSUME_FINISH.name()); - break; - default: - break; - } - } - }; - omsContext.setAbstractContext(context); - listener.consume(omsMsg, omsContext); - - return EventMeshConsumeConcurrentlyStatus.valueOf(contextProperties.getProperty(NonStandardKeys.MESSAGE_CONSUME_STATUS)); - } - }); + rocketmqPushConsumer.registerMessageListener(new ClusteringMessageListener()); } } @@ -195,30 +103,30 @@ public Properties attributes() { return properties; } - @Override + public void start() { if (this.started.compareAndSet(false, true)) { try { this.rocketmqPushConsumer.start(); } catch (Exception e) { - throw new OMSRuntimeException(e.getMessage()); + throw new ConnectorRuntimeException(e.getMessage()); } } } - @Override + public synchronized void shutdown() { if (this.started.compareAndSet(true, false)) { this.rocketmqPushConsumer.shutdown(); } } - @Override + public boolean isStarted() { return this.started.get(); } - @Override + public boolean isClosed() { return !this.isStarted(); } @@ -227,109 +135,182 @@ public DefaultMQPushConsumer getRocketmqPushConsumer() { return rocketmqPushConsumer; } -// class MessageListenerImpl implements MessageListenerConcurrently { -// -// @Override -// public ConsumeConcurrentlyStatus consumeMessage(List rmqMsgList, -// ConsumeConcurrentlyContext contextRMQ) { -// MessageExt rmqMsg = rmqMsgList.get(0); -// BytesMessage omsMsg = OMSUtil.msgConvert(rmqMsg); -// -// MessageListener listener = PushConsumerImpl.this.subscribeTable.get(rmqMsg.getTopic()); -// -// if (listener == null) { -// throw new OMSRuntimeException("-1", -// String.format("The topic/queue %s isn't attached to this consumer", rmqMsg.getTopic())); -// } -// -// final KeyValue contextProperties = OMS.newKeyValue(); -// final CountDownLatch sync = new CountDownLatch(1); -// -// contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, ConsumeConcurrentlyStatus.RECONSUME_LATER.name()); -// -// MessageListener.Context context = new MessageListener.Context() { -// @Override -// public KeyValue attributes() { -// return contextProperties; -// } -// -// @Override -// public void ack() { -// sync.countDown(); -// contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, -// ConsumeConcurrentlyStatus.CONSUME_SUCCESS.name()); -// } -// }; -// long begin = System.currentTimeMillis(); -// listener.onReceived(omsMsg, context); -// long costs = System.currentTimeMillis() - begin; -// long timeoutMills = clientConfig.getRmqMessageConsumeTimeout() * 60 * 1000; -// try { -// sync.await(Math.max(0, timeoutMills - costs), TimeUnit.MILLISECONDS); -// } catch (InterruptedException ignore) { -// } -// -// return ConsumeConcurrentlyStatus.valueOf(contextProperties.getString(NonStandardKeys.MESSAGE_CONSUME_STATUS)); -// } -// } - - @Override - public void subscribe(String topic, String subExpression, MessageListener listener) { + public void subscribe(String topic, String subExpression, EventListener listener) { + this.subscribeTable.put(topic, listener); + try { + this.rocketmqPushConsumer.subscribe(topic, subExpression); + } catch (MQClientException e) { + throw new ConnectorRuntimeException(String.format("RocketMQ push consumer can't attach to %s.", topic)); + } } - @Override - public void subscribe(String topic, MessageSelector selector, MessageListener listener) { + public void unsubscribe(String topic) { + this.subscribeTable.remove(topic); + try { + this.rocketmqPushConsumer.unsubscribe(topic); + } catch (Exception e) { + throw new ConnectorRuntimeException(String.format("RocketMQ push consumer fails to unsubscribe topic: %s", topic)); + } } - @Override - public void subscribe(String topic, String subExpression, GenericMessageListener listener) { - + public void updateOffset(List cloudEvents, AbstractContext context) { + ConsumeMessageService consumeMessageService = rocketmqPushConsumer + .getDefaultMQPushConsumerImpl().getConsumeMessageService(); + List msgExtList = new ArrayList<>(cloudEvents.size()); + for (CloudEvent msg : cloudEvents) { + msgExtList.add(CloudEventUtils.msgConvertExt( + RocketMQMessageFactory.createWriter(msg.getSubject()).writeBinary(msg))); + } + ((ConsumeMessageConcurrentlyService) consumeMessageService) + .updateOffset(msgExtList, (EventMeshConsumeConcurrentlyContext) context); } - @Override - public void subscribe(String topic, MessageSelector selector, GenericMessageListener listener) { - } + private class BroadCastingMessageListener extends EventMeshMessageListenerConcurrently { - @Override - public void subscribe(String topic, String subExpression, AsyncMessageListener listener) { - this.subscribeTable.put(topic, listener); - try { - this.rocketmqPushConsumer.subscribe(topic, subExpression); - } catch (MQClientException e) { - throw new OMSRuntimeException(-1, String.format("RocketMQ push consumer can't attach to %s.", topic)); + @Override + public EventMeshConsumeConcurrentlyStatus handleMessage(MessageExt msg, + EventMeshConsumeConcurrentlyContext context) { + if (msg == null) { + return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS; + } + + msg.putUserProperty(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP, + String.valueOf(msg.getBornTimestamp())); + msg.putUserProperty(Constants.PROPERTY_MESSAGE_STORE_TIMESTAMP, + String.valueOf(msg.getStoreTimestamp())); + + //for rr request/reply + CloudEvent cloudEvent = + RocketMQMessageFactory.createReader(CloudEventUtils.msgConvert(msg)).toEvent(); + + CloudEventBuilder cloudEventBuilder = null; + for (String sysPropKey : MessageConst.STRING_HASH_SET) { + if (StringUtils.isNotEmpty(msg.getProperty(sysPropKey))) { + String prop = msg.getProperty(sysPropKey); + sysPropKey = sysPropKey.toLowerCase().replaceAll("_", Constants.MESSAGE_PROP_SEPARATOR); + cloudEventBuilder = CloudEventBuilder.from(cloudEvent).withExtension(sysPropKey, prop); + } + } + if (cloudEventBuilder != null) { + cloudEvent = cloudEventBuilder.build(); + } + + EventListener listener = PushConsumerImpl.this.subscribeTable.get(msg.getTopic()); + + if (listener == null) { + throw new ConnectorRuntimeException(String.format("The topic/queue %s isn't attached to this consumer", + msg.getTopic())); + } + + final Properties contextProperties = new Properties(); + contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, + EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name()); + AsyncConsumeContext asyncConsumeContext = new AsyncConsumeContext() { + @Override + public void commit(EventMeshAction action) { + switch (action) { + case CommitMessage: + contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, + EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS.name()); + break; + case ReconsumeLater: + contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, + EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name()); + break; + case ManualAck: + contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, + EventMeshConsumeConcurrentlyStatus.CONSUME_FINISH.name()); + break; + default: + break; + } + } + }; + + listener.consume(cloudEvent, asyncConsumeContext); + + return EventMeshConsumeConcurrentlyStatus.valueOf( + contextProperties.getProperty(NonStandardKeys.MESSAGE_CONSUME_STATUS)); } - } - @Override - public void subscribe(String topic, MessageSelector selector, AsyncMessageListener listener) { } - @Override - public void subscribe(String topic, String subExpression, AsyncGenericMessageListener listener) { + private class ClusteringMessageListener extends EventMeshMessageListenerConcurrently { - } + @Override + public EventMeshConsumeConcurrentlyStatus handleMessage(MessageExt msg, + EventMeshConsumeConcurrentlyContext context) { + if (msg == null) { + return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS; + } - @Override - public void subscribe(String topic, MessageSelector selector, AsyncGenericMessageListener listener) { + msg.putUserProperty(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP, + String.valueOf(msg.getBornTimestamp())); + msg.putUserProperty(EventMeshConstants.STORE_TIMESTAMP, + String.valueOf(msg.getStoreTimestamp())); - } + CloudEvent cloudEvent = + RocketMQMessageFactory.createReader(CloudEventUtils.msgConvert(msg)).toEvent(); - @Override - public void unsubscribe(String topic) { - this.subscribeTable.remove(topic); - try { - this.rocketmqPushConsumer.unsubscribe(topic); - } catch (Exception e) { - throw new OMSRuntimeException(-1, String.format("RocketMQ push consumer fails to unsubscribe topic: %s", topic)); + CloudEventBuilder cloudEventBuilder = null; + + for (String sysPropKey : MessageConst.STRING_HASH_SET) { + if (StringUtils.isNotEmpty(msg.getProperty(sysPropKey))) { + String prop = msg.getProperty(sysPropKey); + sysPropKey = sysPropKey.toLowerCase().replaceAll("_", Constants.MESSAGE_PROP_SEPARATOR); + cloudEventBuilder = CloudEventBuilder.from(cloudEvent).withExtension(sysPropKey, prop); + } + } + if (cloudEventBuilder != null) { + cloudEvent = cloudEventBuilder.build(); + } + + EventListener listener = PushConsumerImpl.this.subscribeTable.get(msg.getTopic()); + + if (listener == null) { + throw new ConnectorRuntimeException(String.format("The topic/queue %s isn't attached to this consumer", + msg.getTopic())); + } + + final Properties contextProperties = new Properties(); + + contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, + EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name()); + + EventMeshAsyncConsumeContext eventMeshAsyncConsumeContext = new EventMeshAsyncConsumeContext() { + @Override + public void commit(EventMeshAction action) { + switch (action) { + case CommitMessage: + contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, + EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS.name()); + break; + case ReconsumeLater: + contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, + EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name()); + break; + case ManualAck: + contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, + EventMeshConsumeConcurrentlyStatus.CONSUME_FINISH.name()); + break; + default: + break; + } + } + }; + + eventMeshAsyncConsumeContext.setAbstractContext(context); + + listener.consume(cloudEvent, eventMeshAsyncConsumeContext); + + return EventMeshConsumeConcurrentlyStatus.valueOf( + contextProperties.getProperty(NonStandardKeys.MESSAGE_CONSUME_STATUS)); } } - @Override - public void updateCredential(Properties credentialProperties) { - } } diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java index d103cea839..5e4d4d3c95 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java @@ -18,39 +18,24 @@ package org.apache.eventmesh.connector.rocketmq.consumer; import org.apache.eventmesh.api.AbstractContext; -import org.apache.eventmesh.api.consumer.MeshMQPushConsumer; -import org.apache.eventmesh.connector.rocketmq.MessagingAccessPointImpl; +import org.apache.eventmesh.api.EventListener; +import org.apache.eventmesh.api.consumer.Consumer; import org.apache.eventmesh.connector.rocketmq.common.Constants; -import org.apache.eventmesh.connector.rocketmq.common.EventMeshConstants; import org.apache.eventmesh.connector.rocketmq.config.ClientConfiguration; -import org.apache.eventmesh.connector.rocketmq.config.ConfigurationWrapper; -import org.apache.eventmesh.connector.rocketmq.patch.EventMeshConsumeConcurrentlyContext; -import org.apache.eventmesh.connector.rocketmq.utils.OMSUtil; -import org.apache.rocketmq.client.impl.consumer.ConsumeMessageConcurrentlyService; -import org.apache.rocketmq.client.impl.consumer.ConsumeMessageService; -import org.apache.rocketmq.common.message.MessageExt; import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; -import java.io.File; -import java.util.ArrayList; import java.util.List; import java.util.Properties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import io.openmessaging.api.AsyncGenericMessageListener; -import io.openmessaging.api.AsyncMessageListener; -import io.openmessaging.api.GenericMessageListener; -import io.openmessaging.api.Message; -import io.openmessaging.api.MessageListener; -import io.openmessaging.api.MessageSelector; -import io.openmessaging.api.MessagingAccessPoint; +import io.cloudevents.CloudEvent; +import lombok.extern.slf4j.Slf4j; -public class RocketMQConsumerImpl implements MeshMQPushConsumer { - - public Logger logger = LoggerFactory.getLogger(this.getClass()); +@Slf4j +public class RocketMQConsumerImpl implements Consumer { public Logger messageLogger = LoggerFactory.getLogger("message"); @@ -58,23 +43,19 @@ public class RocketMQConsumerImpl implements MeshMQPushConsumer { @Override public synchronized void init(Properties keyValue) throws Exception { - ConfigurationWrapper configurationWrapper = - new ConfigurationWrapper(getRocketMqConfigFile(), false); - final ClientConfiguration clientConfiguration = - new ClientConfiguration(configurationWrapper); + final ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.init(); boolean isBroadcast = Boolean.parseBoolean(keyValue.getProperty("isBroadcast")); String consumerGroup = keyValue.getProperty("consumerGroup"); String instanceName = keyValue.getProperty("instanceName"); - if (isBroadcast) { consumerGroup = Constants.BROADCAST_PREFIX + consumerGroup; } - String omsNamesrv = clientConfiguration.namesrvAddr; + String namesrvAddr = clientConfiguration.namesrvAddr; Properties properties = new Properties(); - properties.put("ACCESS_POINTS", omsNamesrv); + properties.put("ACCESS_POINTS", namesrvAddr); properties.put("REGION", "namespace"); properties.put("instanceName", instanceName); properties.put("CONSUMER_ID", consumerGroup); @@ -83,12 +64,12 @@ public synchronized void init(Properties keyValue) throws Exception { } else { properties.put("MESSAGE_MODEL", MessageModel.CLUSTERING.name()); } - MessagingAccessPoint messagingAccessPoint = new MessagingAccessPointImpl(properties); - pushConsumer = (PushConsumerImpl) messagingAccessPoint.createConsumer(properties); + + pushConsumer = new PushConsumerImpl(properties); } @Override - public void subscribe(String topic, AsyncMessageListener listener) throws Exception { + public void subscribe(String topic, EventListener listener) throws Exception { pushConsumer.subscribe(topic, "*", listener); } @@ -108,16 +89,8 @@ public synchronized void start() { } @Override - public void updateOffset(List msgs, AbstractContext context) { - ConsumeMessageService consumeMessageService = - pushConsumer.getRocketmqPushConsumer().getDefaultMQPushConsumerImpl() - .getConsumeMessageService(); - List msgExtList = new ArrayList<>(msgs.size()); - for (Message msg : msgs) { - msgExtList.add(OMSUtil.msgConvertExt(msg)); - } - ((ConsumeMessageConcurrentlyService) consumeMessageService) - .updateOffset(msgExtList, (EventMeshConsumeConcurrentlyContext) context); + public void updateOffset(List cloudEvents, AbstractContext context) { + pushConsumer.updateOffset(cloudEvents, context); } @Override @@ -134,65 +107,4 @@ public Properties attributes() { return pushConsumer.attributes(); } - @Override - public void subscribe(String topic, String subExpression, MessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, MessageSelector selector, MessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, String subExpression, - GenericMessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, MessageSelector selector, - GenericMessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, String subExpression, AsyncMessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, MessageSelector selector, AsyncMessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, String subExpression, - AsyncGenericMessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, MessageSelector selector, - AsyncGenericMessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void updateCredential(Properties credentialProperties) { - - } - - private String getRocketMqConfigFile() { - // get from classpath - String configFile = RocketMQConsumerImpl.class.getClassLoader() - .getResource(EventMeshConstants.EVENTMESH_CONF_FILE).getPath(); - if (new File(configFile).exists()) { - return configFile; - } - // get from config home - configFile = EventMeshConstants.EVENTMESH_CONF_HOME + File.separator - + EventMeshConstants.EVENTMESH_CONF_FILE; - return configFile; - } } diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/exception/RMQMessageFormatException.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/exception/RMQMessageFormatException.java new file mode 100644 index 0000000000..703b7ea2bf --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/exception/RMQMessageFormatException.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.eventmesh.connector.rocketmq.exception; + +import org.apache.eventmesh.api.exception.ConnectorRuntimeException; + +public class RMQMessageFormatException extends ConnectorRuntimeException { + + public RMQMessageFormatException(String message) { + super(message); + } + + public RMQMessageFormatException(Throwable throwable) { + super(throwable); + } + + public RMQMessageFormatException(String message, Throwable throwable) { + super(message, throwable); + } +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/exception/RMQTimeoutException.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/exception/RMQTimeoutException.java new file mode 100644 index 0000000000..c2a6b03410 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/exception/RMQTimeoutException.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.eventmesh.connector.rocketmq.exception; + +import org.apache.eventmesh.api.exception.ConnectorRuntimeException; + +public class RMQTimeoutException extends ConnectorRuntimeException { + + public RMQTimeoutException(String message) { + super(message); + } + + public RMQTimeoutException(Throwable throwable) { + super(throwable); + } + + public RMQTimeoutException(String message, Throwable throwable) { + super(message, throwable); + } +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractOMSProducer.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractProducer.java similarity index 69% rename from eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractOMSProducer.java rename to eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractProducer.java index 548077a4ec..3b0b7ce55d 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractOMSProducer.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractProducer.java @@ -20,13 +20,13 @@ import java.util.Properties; import java.util.concurrent.atomic.AtomicBoolean; -import io.openmessaging.api.exception.OMSMessageFormatException; -import io.openmessaging.api.exception.OMSRuntimeException; -import io.openmessaging.api.exception.OMSTimeOutException; - +import org.apache.eventmesh.api.exception.ConnectorRuntimeException; import org.apache.eventmesh.connector.rocketmq.config.ClientConfig; +import org.apache.eventmesh.connector.rocketmq.exception.RMQMessageFormatException; +import org.apache.eventmesh.connector.rocketmq.exception.RMQTimeoutException; import org.apache.eventmesh.connector.rocketmq.utils.BeanUtils; import org.apache.eventmesh.connector.rocketmq.utils.OMSUtil; + import org.apache.rocketmq.client.exception.MQBrokerException; import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl; @@ -38,7 +38,7 @@ import org.apache.rocketmq.remoting.exception.RemotingTimeoutException; import org.apache.rocketmq.remoting.protocol.LanguageCode; -public abstract class AbstractOMSProducer { +public abstract class AbstractProducer { final static InternalLogger log = ClientLogger.getLog(); final Properties properties; @@ -48,14 +48,14 @@ public abstract class AbstractOMSProducer { private final ClientConfig clientConfig; private final String PRODUCER_ID = "PRODUCER_ID"; - AbstractOMSProducer(final Properties properties) { + AbstractProducer(final Properties properties) { this.properties = properties; this.rocketmqProducer = new DefaultMQProducer(); this.clientConfig = BeanUtils.populate(properties, ClientConfig.class); String accessPoints = clientConfig.getAccessPoints(); if (accessPoints == null || accessPoints.isEmpty()) { - throw new OMSRuntimeException(-1, "OMS AccessPoints is null or empty."); + throw new ConnectorRuntimeException("OMS AccessPoints is null or empty."); } this.rocketmqProducer.setNamesrvAddr(accessPoints.replace(',', ';')); @@ -75,7 +75,7 @@ public synchronized void start() { try { this.rocketmqProducer.start(); } catch (MQClientException e) { - throw new OMSRuntimeException("-1", e); + throw new ConnectorRuntimeException("-1", e); } } this.started.set(true); @@ -96,25 +96,30 @@ public boolean isClosed() { return !this.isStarted(); } - OMSRuntimeException checkProducerException(String topic, String msgId, Throwable e) { + ConnectorRuntimeException checkProducerException(String topic, String msgId, Throwable e) { if (e instanceof MQClientException) { if (e.getCause() != null) { if (e.getCause() instanceof RemotingTimeoutException) { - return new OMSTimeOutException(-1, String.format("Send message to broker timeout, %dms, Topic=%s, msgId=%s", + return new RMQTimeoutException( + String.format("Send message to broker timeout, %dms, Topic=%s, msgId=%s", this.rocketmqProducer.getSendMsgTimeout(), topic, msgId), e); - } else if (e.getCause() instanceof MQBrokerException || e.getCause() instanceof RemotingConnectException) { + } else if (e.getCause() instanceof MQBrokerException || + e.getCause() instanceof RemotingConnectException) { if (e.getCause() instanceof MQBrokerException) { MQBrokerException brokerException = (MQBrokerException) e.getCause(); - return new OMSRuntimeException(-1, String.format("Received a broker exception, Topic=%s, msgId=%s, %s", + return new ConnectorRuntimeException( + String.format("Received a broker exception, Topic=%s, msgId=%s, %s", topic, msgId, brokerException.getErrorMessage()), e); } if (e.getCause() instanceof RemotingConnectException) { - RemotingConnectException connectException = (RemotingConnectException) e.getCause(); - return new OMSRuntimeException(-1, - String.format("Network connection experiences failures. Topic=%s, msgId=%s, %s", - topic, msgId, connectException.getMessage()), - e); + RemotingConnectException connectException = + (RemotingConnectException) e.getCause(); + return new ConnectorRuntimeException( + String.format( + "Network connection experiences failures. Topic=%s, msgId=%s, %s", + topic, msgId, connectException.getMessage()), + e); } } } @@ -122,25 +127,33 @@ OMSRuntimeException checkProducerException(String topic, String msgId, Throwable else { MQClientException clientException = (MQClientException) e; if (-1 == clientException.getResponseCode()) { - return new OMSRuntimeException(-1, String.format("Topic does not exist, Topic=%s, msgId=%s", + return new ConnectorRuntimeException( + String.format("Topic does not exist, Topic=%s, msgId=%s", topic, msgId), e); } else if (ResponseCode.MESSAGE_ILLEGAL == clientException.getResponseCode()) { - return new OMSMessageFormatException(-1, String.format("A illegal message for RocketMQ, Topic=%s, msgId=%s", + return new RMQMessageFormatException( + String.format("A illegal message for RocketMQ, Topic=%s, msgId=%s", topic, msgId), e); } } } - return new OMSRuntimeException(-1, "Send message to RocketMQ broker failed.", e); + return new ConnectorRuntimeException("Send message to RocketMQ broker failed.", e); } protected void checkProducerServiceState(DefaultMQProducerImpl producer) { switch (producer.getServiceState()) { case CREATE_JUST: - throw new OMSRuntimeException(String.format("You do not have start the producer, %s", producer.getServiceState())); + throw new ConnectorRuntimeException( + String.format("You do not have start the producer, %s", + producer.getServiceState())); case SHUTDOWN_ALREADY: - throw new OMSRuntimeException(String.format("Your producer has been shut down, %s", producer.getServiceState())); + throw new ConnectorRuntimeException( + String.format("Your producer has been shut down, %s", + producer.getServiceState())); case START_FAILED: - throw new OMSRuntimeException(String.format("When you start your service throws an exception, %s", producer.getServiceState())); + throw new ConnectorRuntimeException( + String.format("When you start your service throws an exception, %s", + producer.getServiceState())); case RUNNING: default: } diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/ProducerImpl.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/ProducerImpl.java index dbad619351..89c6b98b4f 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/ProducerImpl.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/ProducerImpl.java @@ -17,36 +17,37 @@ package org.apache.eventmesh.connector.rocketmq.producer; -import org.apache.eventmesh.api.RRCallback; -import org.apache.eventmesh.connector.rocketmq.utils.OMSUtil; - +import org.apache.eventmesh.api.RequestReplyCallback; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.ConnectorRuntimeException; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.connector.rocketmq.cloudevent.RocketMQMessageFactory; +import org.apache.eventmesh.connector.rocketmq.utils.CloudEventUtils; + +import org.apache.commons.lang3.StringUtils; import org.apache.rocketmq.client.exception.MQBrokerException; import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.client.producer.RequestCallback; +import org.apache.rocketmq.common.MixAll; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.common.message.MessageAccessor; import org.apache.rocketmq.common.message.MessageClientIDSetter; -import org.apache.rocketmq.common.message.MessageExt; +import org.apache.rocketmq.common.message.MessageConst; import org.apache.rocketmq.remoting.exception.RemotingException; import java.util.Properties; -import java.util.concurrent.ExecutorService; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import io.openmessaging.api.Message; -import io.openmessaging.api.MessageBuilder; -import io.openmessaging.api.OnExceptionContext; -import io.openmessaging.api.Producer; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; -import io.openmessaging.api.exception.OMSRuntimeException; +import io.cloudevents.CloudEvent; +import lombok.extern.slf4j.Slf4j; -public class ProducerImpl extends AbstractOMSProducer implements Producer { +@Slf4j +@SuppressWarnings("deprecation") +public class ProducerImpl extends AbstractProducer { public static final int eventMeshServerAsyncAccumulationThreshold = 1000; - private final Logger logger = LoggerFactory.getLogger(ProducerImpl.class); - public ProducerImpl(final Properties properties) { super(properties); } @@ -60,84 +61,122 @@ public void setExtFields() { super.getRocketmqProducer().setRetryTimesWhenSendAsyncFailed(0); super.getRocketmqProducer().setPollNameServerInterval(60000); - super.getRocketmqProducer().getDefaultMQProducerImpl().getmQClientFactory() - .getNettyClientConfig() + super.getRocketmqProducer().getDefaultMQProducerImpl().getmQClientFactory().getNettyClientConfig() .setClientAsyncSemaphoreValue(eventMeshServerAsyncAccumulationThreshold); super.getRocketmqProducer().setCompressMsgBodyOverHowmuch(10); } - @Override - public SendResult send(Message message) { - this.checkProducerServiceState(rocketmqProducer.getDefaultMQProducerImpl()); - org.apache.rocketmq.common.message.Message msgRMQ = OMSUtil.msgConvert(message); + public SendResult send(CloudEvent cloudEvent) { + this.checkProducerServiceState(rocketmqProducer.getDefaultMQProducerImpl()); + org.apache.rocketmq.common.message.Message msg = + RocketMQMessageFactory.createWriter(cloudEvent.getSubject()).writeBinary(cloudEvent); + msg = supplySysProp(msg, cloudEvent); + String messageId = null; try { - org.apache.rocketmq.client.producer.SendResult sendResultRmq = - this.rocketmqProducer.send(msgRMQ); - message.setMsgID(sendResultRmq.getMsgId()); + org.apache.rocketmq.client.producer.SendResult sendResultRmq = this.rocketmqProducer.send(msg); SendResult sendResult = new SendResult(); sendResult.setTopic(sendResultRmq.getMessageQueue().getTopic()); - sendResult.setMessageId(sendResultRmq.getMsgId()); + messageId = sendResultRmq.getMsgId(); + sendResult.setMessageId(messageId); return sendResult; } catch (Exception e) { - log.error(String.format("Send message Exception, %s", message), e); - throw this.checkProducerException(message.getTopic(), message.getMsgID(), e); + log.error(String.format("Send message Exception, %s", msg), e); + throw this.checkProducerException(msg.getTopic(), messageId, e); } } - @Override - public void sendOneway(Message message) { - this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl()); - org.apache.rocketmq.common.message.Message msgRMQ = OMSUtil.msgConvert(message); + public void sendOneway(CloudEvent cloudEvent) { + this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl()); + org.apache.rocketmq.common.message.Message msg = + RocketMQMessageFactory.createWriter(cloudEvent.getSubject()).writeBinary(cloudEvent); + msg = supplySysProp(msg, cloudEvent); try { - this.rocketmqProducer.sendOneway(msgRMQ); - message.setMsgID(MessageClientIDSetter.getUniqID(msgRMQ)); + this.rocketmqProducer.sendOneway(msg); } catch (Exception e) { - log.error(String.format("Send message oneway Exception, %s", message), e); - throw this.checkProducerException(message.getTopic(), message.getMsgID(), e); + log.error(String.format("Send message oneway Exception, %s", msg), e); + throw this.checkProducerException(msg.getTopic(), MessageClientIDSetter.getUniqID(msg), e); } } - @Override - public void sendAsync(Message message, SendCallback sendCallback) { - this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl()); - org.apache.rocketmq.common.message.Message msgRMQ = OMSUtil.msgConvert(message); + public void sendAsync(CloudEvent cloudEvent, SendCallback sendCallback) { + this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl()); + org.apache.rocketmq.common.message.Message msg = + RocketMQMessageFactory.createWriter(cloudEvent.getSubject()).writeBinary(cloudEvent); + msg = supplySysProp(msg, cloudEvent); try { - this.rocketmqProducer.send(msgRMQ, this.sendCallbackConvert(message, sendCallback)); - message.setMsgID(MessageClientIDSetter.getUniqID(msgRMQ)); + this.rocketmqProducer.send(msg, this.sendCallbackConvert(msg, sendCallback)); } catch (Exception e) { - log.error(String.format("Send message async Exception, %s", message), e); - throw this.checkProducerException(message.getTopic(), message.getMsgID(), e); + log.error(String.format("Send message async Exception, %s", msg), e); + throw this.checkProducerException(msg.getTopic(), MessageClientIDSetter.getUniqID(msg), e); } } - public void request(Message message, RRCallback rrCallback, long timeout) + public void request(CloudEvent cloudEvent, RequestReplyCallback rrCallback, long timeout) throws InterruptedException, RemotingException, MQClientException, MQBrokerException { this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl()); - org.apache.rocketmq.common.message.Message msgRMQ = OMSUtil.msgConvert(message); - rocketmqProducer.request(msgRMQ, rrCallbackConvert(message, rrCallback), timeout); + org.apache.rocketmq.common.message.Message msg = + RocketMQMessageFactory.createWriter(cloudEvent.getSubject()).writeBinary(cloudEvent); + + msg = supplySysProp(msg, cloudEvent); + + rocketmqProducer.request(msg, rrCallbackConvert(msg, rrCallback), timeout); + } + + public boolean reply(final CloudEvent cloudEvent, final SendCallback sendCallback) { + this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl()); + org.apache.rocketmq.common.message.Message msg = + RocketMQMessageFactory.createWriter(cloudEvent.getSubject()).writeBinary(cloudEvent); + MessageAccessor.putProperty(msg, MessageConst.PROPERTY_MESSAGE_TYPE, MixAll.REPLY_MESSAGE_FLAG); + msg = supplySysProp(msg, cloudEvent); + + try { + this.rocketmqProducer.send(msg, this.sendCallbackConvert(msg, sendCallback)); + } catch (Exception e) { + log.error(String.format("Send message async Exception, %s", msg), e); + throw this.checkProducerException(msg.getTopic(), MessageClientIDSetter.getUniqID(msg), e); + } + return true; + + } + + private Message supplySysProp(Message msg, CloudEvent cloudEvent) { + for (String sysPropKey : MessageConst.STRING_HASH_SET) { + String ceKey = sysPropKey.toLowerCase().replaceAll("_", Constants.MESSAGE_PROP_SEPARATOR); + if (cloudEvent.getExtension(ceKey) != null && StringUtils.isNotEmpty(cloudEvent.getExtension(ceKey).toString())) { + MessageAccessor.putProperty(msg, sysPropKey, cloudEvent.getExtension(ceKey).toString()); + msg.getProperties().remove(ceKey); + } + } + return msg; } - private RequestCallback rrCallbackConvert(final Message message, final RRCallback rrCallback) { + private RequestCallback rrCallbackConvert(final Message message, final RequestReplyCallback rrCallback) { return new RequestCallback() { @Override public void onSuccess(org.apache.rocketmq.common.message.Message message) { - Message openMessage = OMSUtil.msgConvert((MessageExt) message); - rrCallback.onSuccess(openMessage); + // clean the message property to lowercase + for (String sysPropKey : MessageConst.STRING_HASH_SET) { + if (StringUtils.isNotEmpty(message.getProperty(sysPropKey))) { + String prop = message.getProperty(sysPropKey); + String tmpPropKey = sysPropKey.toLowerCase().replaceAll("_", Constants.MESSAGE_PROP_SEPARATOR); + MessageAccessor.putProperty(message, tmpPropKey, prop); + message.getProperties().remove(sysPropKey); + } + } + CloudEvent event = RocketMQMessageFactory.createReader(message).toEvent(); + rrCallback.onSuccess(event); } @Override public void onException(Throwable e) { String topic = message.getTopic(); - String msgId = message.getMsgID(); - OMSRuntimeException onsEx = - ProducerImpl.this.checkProducerException(topic, msgId, e); + ConnectorRuntimeException onsEx = ProducerImpl.this.checkProducerException(topic, null, e); OnExceptionContext context = new OnExceptionContext(); context.setTopic(topic); - context.setMessageId(msgId); context.setException(onsEx); rrCallback.onException(e); @@ -145,24 +184,21 @@ public void onException(Throwable e) { }; } - private org.apache.rocketmq.client.producer.SendCallback sendCallbackConvert( - final Message message, final SendCallback sendCallback) { + private org.apache.rocketmq.client.producer.SendCallback sendCallbackConvert(final Message message, + final SendCallback sendCallback) { org.apache.rocketmq.client.producer.SendCallback rmqSendCallback = new org.apache.rocketmq.client.producer.SendCallback() { @Override public void onSuccess(org.apache.rocketmq.client.producer.SendResult sendResult) { - sendCallback.onSuccess(OMSUtil.sendResultConvert(sendResult)); + sendCallback.onSuccess(CloudEventUtils.convertSendResult(sendResult)); } @Override public void onException(Throwable e) { String topic = message.getTopic(); - String msgId = message.getMsgID(); - OMSRuntimeException onsEx = - ProducerImpl.this.checkProducerException(topic, msgId, e); + ConnectorRuntimeException onsEx = ProducerImpl.this.checkProducerException(topic, null, e); OnExceptionContext context = new OnExceptionContext(); context.setTopic(topic); - context.setMessageId(msgId); context.setException(onsEx); sendCallback.onException(context); } @@ -170,18 +206,4 @@ public void onException(Throwable e) { return rmqSendCallback; } - @Override - public void setCallbackExecutor(ExecutorService callbackExecutor) { -// this.rocketmqProducer.setCallbackExecutor(callbackExecutor); - } - - @Override - public void updateCredential(Properties credentialProperties) { - - } - - @Override - public MessageBuilder messageBuilder() { - return null; - } } diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java index 75e2360ba1..47ed2b1d83 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java @@ -17,45 +17,31 @@ package org.apache.eventmesh.connector.rocketmq.producer; -import java.io.File; -import java.util.Properties; -import java.util.concurrent.ExecutorService; - -import io.openmessaging.api.Message; -import io.openmessaging.api.MessageBuilder; -import io.openmessaging.api.MessagingAccessPoint; -import io.openmessaging.api.OMS; -import io.openmessaging.api.OMSBuiltinKeys; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; - -import org.apache.eventmesh.api.RRCallback; -import org.apache.eventmesh.api.producer.MeshMQProducer; -import org.apache.eventmesh.connector.rocketmq.MessagingAccessPointImpl; +import org.apache.eventmesh.api.RequestReplyCallback; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.producer.Producer; import org.apache.eventmesh.connector.rocketmq.common.EventMeshConstants; import org.apache.eventmesh.connector.rocketmq.config.ClientConfiguration; -import org.apache.eventmesh.connector.rocketmq.config.ConfigurationWrapper; + import org.apache.rocketmq.client.exception.MQBrokerException; import org.apache.rocketmq.client.exception.MQClientException; -import org.apache.rocketmq.common.MixAll; -import org.apache.rocketmq.common.message.MessageConst; import org.apache.rocketmq.remoting.exception.RemotingException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -public class RocketMQProducerImpl implements MeshMQProducer { +import java.util.Properties; + +import io.cloudevents.CloudEvent; +import lombok.extern.slf4j.Slf4j; - public Logger logger = LoggerFactory.getLogger(this.getClass()); +@Slf4j +@SuppressWarnings("deprecation") +public class RocketMQProducerImpl implements Producer { private ProducerImpl producer; @Override public synchronized void init(Properties keyValue) { - ConfigurationWrapper configurationWrapper = - new ConfigurationWrapper(EventMeshConstants.EVENTMESH_CONF_HOME - + File.separator - + EventMeshConstants.EVENTMESH_CONF_FILE, false); - final ClientConfiguration clientConfiguration = new ClientConfiguration(configurationWrapper); + final ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.init(); String producerGroup = keyValue.getProperty("producerGroup"); @@ -67,8 +53,7 @@ public synchronized void init(Properties keyValue) { properties.put("OPERATION_TIMEOUT", 3000); properties.put("PRODUCER_ID", producerGroup); - MessagingAccessPoint messagingAccessPoint = new MessagingAccessPointImpl(properties); - producer = (ProducerImpl) messagingAccessPoint.createProducer(properties); + producer = new ProducerImpl(properties); } @@ -93,26 +78,26 @@ public synchronized void shutdown() { } @Override - public void send(Message message, SendCallback sendCallback) throws Exception { + public void publish(CloudEvent message, SendCallback sendCallback) throws Exception { producer.sendAsync(message, sendCallback); } @Override - public void request(Message message, RRCallback rrCallback, long timeout) - throws InterruptedException, RemotingException, MQClientException, MQBrokerException { + public void request(CloudEvent message, RequestReplyCallback rrCallback, long timeout) + throws InterruptedException, RemotingException, MQClientException, MQBrokerException { producer.request(message, rrCallback, timeout); } @Override - public boolean reply(final Message message, final SendCallback sendCallback) throws Exception { - message.putSystemProperties(MessageConst.PROPERTY_MESSAGE_TYPE, MixAll.REPLY_MESSAGE_FLAG); - producer.sendAsync(message, sendCallback); + public boolean reply(final CloudEvent message, final SendCallback sendCallback) throws Exception { + producer.reply(message, sendCallback); return true; } @Override public void checkTopicExist(String topic) throws Exception { - this.producer.getRocketmqProducer().getDefaultMQProducerImpl().getmQClientFactory().getMQClientAPIImpl().getDefaultTopicRouteInfoFromNameServer(topic, EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS); + this.producer.getRocketmqProducer().getDefaultMQProducerImpl().getmQClientFactory().getMQClientAPIImpl() + .getDefaultTopicRouteInfoFromNameServer(topic, EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS); } @Override @@ -121,32 +106,19 @@ public void setExtFields() { } @Override - public SendResult send(Message message) { + public SendResult publish(CloudEvent message) { return producer.send(message); } @Override - public void sendOneway(Message message) { + public void sendOneway(CloudEvent message) { producer.sendOneway(message); } @Override - public void sendAsync(Message message, SendCallback sendCallback) { + public void sendAsync(CloudEvent message, SendCallback sendCallback) { producer.sendAsync(message, sendCallback); } - @Override - public void setCallbackExecutor(ExecutorService callbackExecutor) { - producer.setCallbackExecutor(callbackExecutor); - } - - @Override - public void updateCredential(Properties credentialProperties) { - producer.updateCredential(credentialProperties); - } - @Override - public MessageBuilder messageBuilder() { - return null; - } } diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/promise/DefaultPromise.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/promise/DefaultPromise.java deleted file mode 100644 index cc30eb5ab0..0000000000 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/promise/DefaultPromise.java +++ /dev/null @@ -1,227 +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 org.apache.eventmesh.connector.rocketmq.promise; - -import java.util.ArrayList; -import java.util.List; - -import io.openmessaging.api.Future; -import io.openmessaging.api.FutureListener; -import io.openmessaging.api.exception.OMSRuntimeException; - -import org.apache.rocketmq.logging.InternalLogger; -import org.apache.rocketmq.logging.InternalLoggerFactory; - -public class DefaultPromise implements Future { - private static final InternalLogger LOG = InternalLoggerFactory.getLogger(DefaultPromise.class); - private final Object lock = new Object(); - private volatile FutureState state = FutureState.DOING; - private V result = null; - private long timeout; - private long createTime; - private Throwable exception = null; - private List> promiseListenerList; - - public DefaultPromise() { - createTime = System.currentTimeMillis(); - promiseListenerList = new ArrayList<>(); - timeout = 5000; - } - - @Override - public boolean cancel(final boolean mayInterruptIfRunning) { - return false; - } - - @Override - public boolean isCancelled() { - return state.isCancelledState(); - } - - @Override - public boolean isDone() { - return state.isDoneState(); - } - - @Override - public V get() { - return result; - } - - @Override - public V get(final long timeout) { - synchronized (lock) { - if (!isDoing()) { - return getValueOrThrowable(); - } - - if (timeout <= 0) { - try { - lock.wait(); - } catch (Exception e) { - cancel(e); - } - return getValueOrThrowable(); - } else { - long waitTime = timeout - (System.currentTimeMillis() - createTime); - if (waitTime > 0) { - for (; ; ) { - try { - lock.wait(waitTime); - } catch (InterruptedException e) { - LOG.error("promise get value interrupted,excepiton:{}", e.getMessage()); - } - - if (!isDoing()) { - break; - } else { - waitTime = timeout - (System.currentTimeMillis() - createTime); - if (waitTime <= 0) { - break; - } - } - } - } - - if (isDoing()) { - timeoutSoCancel(); - } - } - return getValueOrThrowable(); - } - } - - public boolean set(final V value) { - if (value == null) { - return false; - } - this.result = value; - return done(); - } - - public boolean setFailure(final Throwable cause) { - if (cause == null) { - return false; - } - this.exception = cause; - return done(); - } - - @Override - public void addListener(final FutureListener listener) { - if (listener == null) { - throw new NullPointerException("FutureListener is null"); - } - - boolean notifyNow = false; - synchronized (lock) { - if (!isDoing()) { - notifyNow = true; - } else { - if (promiseListenerList == null) { - promiseListenerList = new ArrayList<>(); - } - promiseListenerList.add(listener); - } - } - - if (notifyNow) { - notifyListener(listener); - } - } - - @Override - public Throwable getThrowable() { - return exception; - } - - private void notifyListeners() { - if (promiseListenerList != null) { - for (FutureListener listener : promiseListenerList) { - notifyListener(listener); - } - } - } - - private boolean isSuccess() { - return isDone() && (exception == null); - } - - private void timeoutSoCancel() { - synchronized (lock) { - if (!isDoing()) { - return; - } - state = FutureState.CANCELLED; - exception = new RuntimeException("Get request result is timeout or interrupted"); - lock.notifyAll(); - } - notifyListeners(); - } - - private V getValueOrThrowable() { - if (exception != null) { - Throwable e = exception.getCause() != null ? exception.getCause() : exception; - throw new OMSRuntimeException("-1", e); - } - notifyListeners(); - return result; - } - - private boolean isDoing() { - return state.isDoingState(); - } - - private boolean done() { - synchronized (lock) { - if (!isDoing()) { - return false; - } - - state = FutureState.DONE; - lock.notifyAll(); - } - - notifyListeners(); - return true; - } - - private void notifyListener(final FutureListener listener) { - try { - listener.operationComplete(this); - } catch (Throwable t) { - LOG.error("notifyListener {} Error:{}", listener.getClass().getSimpleName(), t); - } - } - - private boolean cancel(Exception e) { - synchronized (lock) { - if (!isDoing()) { - return false; - } - - state = FutureState.CANCELLED; - exception = e; - lock.notifyAll(); - } - - notifyListeners(); - return true; - } -} - diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/CloudEventUtils.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/CloudEventUtils.java new file mode 100644 index 0000000000..2073468895 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/CloudEventUtils.java @@ -0,0 +1,152 @@ +/* + * Licensed 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.eventmesh.connector.rocketmq.utils; + +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.common.Constants; + +import org.apache.commons.lang3.StringUtils; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.common.message.MessageAccessor; +import org.apache.rocketmq.common.message.MessageConst; +import org.apache.rocketmq.common.message.MessageExt; + +import java.util.Map; +import java.util.Set; + +public class CloudEventUtils { + + public static SendResult convertSendResult( + org.apache.rocketmq.client.producer.SendResult rmqResult) { + SendResult sendResult = new SendResult(); + sendResult.setTopic(rmqResult.getMessageQueue().getTopic()); + sendResult.setMessageId(rmqResult.getMsgId()); + return sendResult; + } + + + public static Message msgConvert(MessageExt rmqMsg) { + Message message = new Message(); + if (rmqMsg.getTopic() != null) { + message.setTopic(rmqMsg.getTopic()); + } + + if (rmqMsg.getKeys() != null) { + message.setKeys(rmqMsg.getKeys()); + } + + if (rmqMsg.getTags() != null) { + message.setTags(rmqMsg.getTags()); + } + + if (rmqMsg.getBody() != null) { + message.setBody(rmqMsg.getBody()); + } + + final Set> entries = rmqMsg.getProperties().entrySet(); + + for (final Map.Entry entry : entries) { + MessageAccessor.putProperty(message, entry.getKey(), entry.getValue()); + } + + if (rmqMsg.getMsgId() != null) { + MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_MESSAGE_ID), + rmqMsg.getMsgId()); + } + + if (rmqMsg.getTopic() != null) { + MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_DESTINATION), + rmqMsg.getTopic()); + } + + // + MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_BORN_HOST), + String.valueOf(rmqMsg.getBornHost())); + MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP), + String.valueOf(rmqMsg.getBornTimestamp())); + MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_STORE_HOST), + String.valueOf(rmqMsg.getStoreHost())); + MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_STORE_TIMESTAMP), + String.valueOf(rmqMsg.getStoreTimestamp())); + + //use in manual ack + MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_QUEUE_ID), + String.valueOf(rmqMsg.getQueueId())); + MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_QUEUE_OFFSET), + String.valueOf(rmqMsg.getQueueOffset())); + + for (String sysPropKey : MessageConst.STRING_HASH_SET) { + if (StringUtils.isNotEmpty(message.getProperty(sysPropKey))) { + String prop = message.getProperty(sysPropKey); + String tmpPropKey = sysPropKey.toLowerCase().replaceAll("_", Constants.MESSAGE_PROP_SEPARATOR); + MessageAccessor.putProperty(message, tmpPropKey, prop); + message.getProperties().remove(sysPropKey); + } + } + + return message; + } + + + + private static String buildCloudEventPropertyKey(String propName) { + //return RocketMQHeaders.CE_PREFIX + propName; + return propName; + } + + public static org.apache.rocketmq.common.message.MessageExt msgConvertExt(Message message) { + + org.apache.rocketmq.common.message.MessageExt rmqMessageExt = + new org.apache.rocketmq.common.message.MessageExt(); + try { + if (message.getKeys() != null) { + rmqMessageExt.setKeys(message.getKeys()); + } + if (message.getTags() != null) { + rmqMessageExt.setTags(message.getTags()); + } + + + if (message.getBody() != null) { + rmqMessageExt.setBody(message.getBody()); + } + + + //All destinations in RocketMQ use Topic + rmqMessageExt.setTopic(message.getTopic()); + + int queueId = + Integer.parseInt(message.getProperty(buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_QUEUE_ID))); + long queueOffset = Long.parseLong( + message.getProperty(buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_QUEUE_OFFSET))); + //use in manual ack + rmqMessageExt.setQueueId(queueId); + rmqMessageExt.setQueueOffset(queueOffset); + Map properties = message.getProperties(); + for (final Map.Entry entry : properties.entrySet()) { + MessageAccessor.putProperty(rmqMessageExt, entry.getKey(), entry.getValue()); + } + } catch (Exception e) { + e.printStackTrace(); + } + return rmqMessageExt; + + } + + +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/OMSUtil.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/OMSUtil.java index 00bcb85f2a..dd2a36bd8a 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/OMSUtil.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/OMSUtil.java @@ -24,10 +24,6 @@ import java.util.Properties; import java.util.Set; -import io.openmessaging.api.Message; -import io.openmessaging.api.OMSBuiltinKeys; -import io.openmessaging.api.SendResult; -import io.openmessaging.api.exception.OMSRuntimeException; import org.apache.eventmesh.common.Constants; import org.apache.rocketmq.common.UtilAll; @@ -42,255 +38,255 @@ public class OMSUtil { * @return a unique instance name */ public static String buildInstanceName() { - return Integer.toString(UtilAll.getPid()) + "%OpenMessaging" + "%" + System.nanoTime(); + return Integer.toString(UtilAll.getPid()) + "%EventMesh" + "%" + System.nanoTime(); } - public static org.apache.rocketmq.common.message.Message msgConvert(Message omsMessage) { - org.apache.rocketmq.common.message.Message rmqMessage = new org.apache.rocketmq.common.message.Message(); - if (omsMessage == null) { - throw new OMSRuntimeException("'message' is null"); - } else { - if (omsMessage.getTopic() != null) { - rmqMessage.setTopic(omsMessage.getTopic()); - } - if (omsMessage.getKey() != null) { - rmqMessage.setKeys(omsMessage.getKey()); - } - if (omsMessage.getTag() != null) { - rmqMessage.setTags(omsMessage.getTag()); - } - if (omsMessage.getStartDeliverTime() > 0L) { - rmqMessage.putUserProperty("TIMER_DELIVER_MS", String.valueOf(omsMessage.getStartDeliverTime())); - } - - if (omsMessage.getBody() != null) { - rmqMessage.setBody(omsMessage.getBody()); - } - - if (omsMessage.getShardingKey() != null && !omsMessage.getShardingKey().isEmpty()) { - rmqMessage.putUserProperty("__SHARDINGKEY", omsMessage.getShardingKey()); - } - } - Properties systemProperties = omsMessage.getSystemProperties(); - Properties userProperties = omsMessage.getUserProperties(); - - //All destinations in RocketMQ use Topic -// rmqMessage.setTopic(systemProperties.getProperty(BuiltinKeys.DESTINATION)); - -// if (sysHeaders.containsKey(BuiltinKeys.START_TIME)) { -// long deliverTime = sysHeaders.getLong(BuiltinKeys.START_TIME, 0); -// if (deliverTime > 0) { -// rmqMessage.putUserProperty(RocketMQConstants.START_DELIVER_TIME, String.valueOf(deliverTime)); +// public static org.apache.rocketmq.common.message.Message msgConvert(Message omsMessage) { +// org.apache.rocketmq.common.message.Message rmqMessage = new org.apache.rocketmq.common.message.Message(); +// if (omsMessage == null) { +// throw new OMSRuntimeException("'message' is null"); +// } else { +// if (omsMessage.getTopic() != null) { +// rmqMessage.setTopic(omsMessage.getTopic()); +// } +// if (omsMessage.getKey() != null) { +// rmqMessage.setKeys(omsMessage.getKey()); +// } +// if (omsMessage.getTag() != null) { +// rmqMessage.setTags(omsMessage.getTag()); +// } +// if (omsMessage.getStartDeliverTime() > 0L) { +// rmqMessage.putUserProperty("TIMER_DELIVER_MS", String.valueOf(omsMessage.getStartDeliverTime())); +// } +// +// if (omsMessage.getBody() != null) { +// rmqMessage.setBody(omsMessage.getBody()); +// } +// +// if (omsMessage.getShardingKey() != null && !omsMessage.getShardingKey().isEmpty()) { +// rmqMessage.putUserProperty("__SHARDINGKEY", omsMessage.getShardingKey()); // } // } - - for (String key : userProperties.stringPropertyNames()) { - MessageAccessor.putProperty(rmqMessage, key, userProperties.getProperty(key)); - } - - //System headers has a high priority - for (String key : systemProperties.stringPropertyNames()) { - MessageAccessor.putProperty(rmqMessage, key, systemProperties.getProperty(key)); - } - - return rmqMessage; - } - - public static Message msgConvert(MessageExt rmqMsg) { - Message message = new Message(); - if (rmqMsg.getTopic() != null) { - message.setTopic(rmqMsg.getTopic()); - } - - if (rmqMsg.getKeys() != null) { - message.setKey(rmqMsg.getKeys()); - } - - if (rmqMsg.getTags() != null) { - message.setTag(rmqMsg.getTags()); - } - - if (rmqMsg.getBody() != null) { - message.setBody(rmqMsg.getBody()); - } - - if (rmqMsg.getUserProperty("TIMER_DELIVER_MS") != null) { - long ms = Long.parseLong(rmqMsg.getUserProperty("TIMER_DELIVER_MS")); - rmqMsg.getProperties().remove("TIMER_DELIVER_MS"); - message.setStartDeliverTime(ms); - } - - Properties systemProperties = new Properties(); - Properties userProperties = new Properties(); - - - final Set> entries = rmqMsg.getProperties().entrySet(); - - for (final Map.Entry entry : entries) { - if (isOMSHeader(entry.getKey())) { - //sysHeader - systemProperties.put(entry.getKey(), entry.getValue()); - } else { - //userHeader - userProperties.put(entry.getKey(), entry.getValue()); - } - } - - if (rmqMsg.getMsgId() != null){ - systemProperties.put(Constants.PROPERTY_MESSAGE_MESSAGE_ID, rmqMsg.getMsgId()); - } - - if (rmqMsg.getTopic() != null){ - systemProperties.put(Constants.PROPERTY_MESSAGE_DESTINATION, rmqMsg.getTopic()); - } - -// omsMsg.putSysHeaders(BuiltinKeys.SEARCH_KEYS, rmqMsg.getKeys()); - systemProperties.put(Constants.PROPERTY_MESSAGE_BORN_HOST, String.valueOf(rmqMsg.getBornHost())); - systemProperties.put(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP, rmqMsg.getBornTimestamp()); - systemProperties.put(Constants.PROPERTY_MESSAGE_STORE_HOST, String.valueOf(rmqMsg.getStoreHost())); - systemProperties.put("STORE_TIMESTAMP", rmqMsg.getStoreTimestamp()); - - //use in manual ack - userProperties.put(Constants.PROPERTY_MESSAGE_QUEUE_ID, rmqMsg.getQueueId()); - userProperties.put(Constants.PROPERTY_MESSAGE_QUEUE_OFFSET, rmqMsg.getQueueOffset()); - - message.setSystemProperties(systemProperties); - message.setUserProperties(userProperties); - - return message; - } - - public static org.apache.rocketmq.common.message.MessageExt msgConvertExt(Message omsMessage) { - - org.apache.rocketmq.common.message.MessageExt rmqMessageExt = new org.apache.rocketmq.common.message.MessageExt(); - try { - if (omsMessage.getKey() != null) { - rmqMessageExt.setKeys(omsMessage.getKey()); - } - if (omsMessage.getTag() != null) { - rmqMessageExt.setTags(omsMessage.getTag()); - } - if (omsMessage.getStartDeliverTime() > 0L) { - rmqMessageExt.putUserProperty("TIMER_DELIVER_MS", String.valueOf(omsMessage.getStartDeliverTime())); - } - - if (omsMessage.getBody() != null) { - rmqMessageExt.setBody(omsMessage.getBody()); - } - - if (omsMessage.getShardingKey() != null && !omsMessage.getShardingKey().isEmpty()) { - rmqMessageExt.putUserProperty("__SHARDINGKEY", omsMessage.getShardingKey()); - } - - Properties systemProperties = omsMessage.getSystemProperties(); - Properties userProperties = omsMessage.getUserProperties(); - - //All destinations in RocketMQ use Topic - rmqMessageExt.setTopic(omsMessage.getTopic()); - - int queueId = (int) userProperties.get(Constants.PROPERTY_MESSAGE_QUEUE_ID); - long queueOffset = (long) userProperties.get(Constants.PROPERTY_MESSAGE_QUEUE_OFFSET); - //use in manual ack - rmqMessageExt.setQueueId(queueId); - rmqMessageExt.setQueueOffset(queueOffset); - - for (String key : userProperties.stringPropertyNames()) { - MessageAccessor.putProperty(rmqMessageExt, key, userProperties.getProperty(key)); - } - - //System headers has a high priority - for (String key : systemProperties.stringPropertyNames()) { - MessageAccessor.putProperty(rmqMessageExt, key, systemProperties.getProperty(key)); - } - - } catch (Exception e) { - e.printStackTrace(); - } - return rmqMessageExt; - - } - - public static boolean isOMSHeader(String value) { - for (Field field : OMSBuiltinKeys.class.getDeclaredFields()) { - try { - if (field.get(OMSBuiltinKeys.class).equals(value)) { - return true; - } - } catch (IllegalAccessException e) { - return false; - } - } - return false; - } - - /** - * Convert a RocketMQ SEND_OK SendResult instance to a OMS SendResult. - * - * @param rmqResult RocketMQ result - * @return send result - */ - public static SendResult sendResultConvert(org.apache.rocketmq.client.producer.SendResult rmqResult) { - SendResult sendResult = new SendResult(); - sendResult.setTopic(rmqResult.getMessageQueue().getTopic()); - sendResult.setMessageId(rmqResult.getMsgId()); - return sendResult; - } - -// public static KeyValue buildKeyValue(KeyValue... keyValues) { -// KeyValue keyValue = OMS.newKeyValue(); -// for (KeyValue properties : keyValues) { -// for (String key : properties.keySet()) { -// keyValue.put(key, properties.getString(key)); +// Properties systemProperties = omsMessage.getSystemProperties(); +// Properties userProperties = omsMessage.getUserProperties(); +// +// //All destinations in RocketMQ use Topic +//// rmqMessage.setTopic(systemProperties.getProperty(BuiltinKeys.DESTINATION)); +// +//// if (sysHeaders.containsKey(BuiltinKeys.START_TIME)) { +//// long deliverTime = sysHeaders.getLong(BuiltinKeys.START_TIME, 0); +//// if (deliverTime > 0) { +//// rmqMessage.putUserProperty(RocketMQConstants.START_DELIVER_TIME, String.valueOf(deliverTime)); +//// } +//// } +// +// for (String key : userProperties.stringPropertyNames()) { +// MessageAccessor.putProperty(rmqMessage, key, userProperties.getProperty(key)); +// } +// +// //System headers has a high priority +// for (String key : systemProperties.stringPropertyNames()) { +// MessageAccessor.putProperty(rmqMessage, key, systemProperties.getProperty(key)); +// } +// +// return rmqMessage; +// } +// +// public static Message msgConvert(MessageExt rmqMsg) { +// Message message = new Message(); +// if (rmqMsg.getTopic() != null) { +// message.setTopic(rmqMsg.getTopic()); +// } +// +// if (rmqMsg.getKeys() != null) { +// message.setKey(rmqMsg.getKeys()); +// } +// +// if (rmqMsg.getTags() != null) { +// message.setTag(rmqMsg.getTags()); +// } +// +// if (rmqMsg.getBody() != null) { +// message.setBody(rmqMsg.getBody()); +// } +// +// if (rmqMsg.getUserProperty("TIMER_DELIVER_MS") != null) { +// long ms = Long.parseLong(rmqMsg.getUserProperty("TIMER_DELIVER_MS")); +// rmqMsg.getProperties().remove("TIMER_DELIVER_MS"); +// message.setStartDeliverTime(ms); +// } +// +// Properties systemProperties = new Properties(); +// Properties userProperties = new Properties(); +// +// +// final Set> entries = rmqMsg.getProperties().entrySet(); +// +// for (final Map.Entry entry : entries) { +// if (isOMSHeader(entry.getKey())) { +// //sysHeader +// systemProperties.put(entry.getKey(), entry.getValue()); +// } else { +// //userHeader +// userProperties.put(entry.getKey(), entry.getValue()); // } // } -// return keyValue; +// +// if (rmqMsg.getMsgId() != null){ +// systemProperties.put(Constants.PROPERTY_MESSAGE_MESSAGE_ID, rmqMsg.getMsgId()); +// } +// +// if (rmqMsg.getTopic() != null){ +// systemProperties.put(Constants.PROPERTY_MESSAGE_DESTINATION, rmqMsg.getTopic()); +// } +// +//// omsMsg.putSysHeaders(BuiltinKeys.SEARCH_KEYS, rmqMsg.getKeys()); +// systemProperties.put(Constants.PROPERTY_MESSAGE_BORN_HOST, String.valueOf(rmqMsg.getBornHost())); +// systemProperties.put(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP, rmqMsg.getBornTimestamp()); +// systemProperties.put(Constants.PROPERTY_MESSAGE_STORE_HOST, String.valueOf(rmqMsg.getStoreHost())); +// systemProperties.put("STORE_TIMESTAMP", rmqMsg.getStoreTimestamp()); +// +// //use in manual ack +// userProperties.put(Constants.PROPERTY_MESSAGE_QUEUE_ID, rmqMsg.getQueueId()); +// userProperties.put(Constants.PROPERTY_MESSAGE_QUEUE_OFFSET, rmqMsg.getQueueOffset()); +// +// message.setSystemProperties(systemProperties); +// message.setUserProperties(userProperties); +// +// return message; +// } +// +// public static org.apache.rocketmq.common.message.MessageExt msgConvertExt(Message omsMessage) { +// +// org.apache.rocketmq.common.message.MessageExt rmqMessageExt = new org.apache.rocketmq.common.message.MessageExt(); +// try { +// if (omsMessage.getKey() != null) { +// rmqMessageExt.setKeys(omsMessage.getKey()); +// } +// if (omsMessage.getTag() != null) { +// rmqMessageExt.setTags(omsMessage.getTag()); +// } +// if (omsMessage.getStartDeliverTime() > 0L) { +// rmqMessageExt.putUserProperty("TIMER_DELIVER_MS", String.valueOf(omsMessage.getStartDeliverTime())); +// } +// +// if (omsMessage.getBody() != null) { +// rmqMessageExt.setBody(omsMessage.getBody()); +// } +// +// if (omsMessage.getShardingKey() != null && !omsMessage.getShardingKey().isEmpty()) { +// rmqMessageExt.putUserProperty("__SHARDINGKEY", omsMessage.getShardingKey()); +// } +// +// Properties systemProperties = omsMessage.getSystemProperties(); +// Properties userProperties = omsMessage.getUserProperties(); +// +// //All destinations in RocketMQ use Topic +// rmqMessageExt.setTopic(omsMessage.getTopic()); +// +// int queueId = (int) userProperties.get(Constants.PROPERTY_MESSAGE_QUEUE_ID); +// long queueOffset = (long) userProperties.get(Constants.PROPERTY_MESSAGE_QUEUE_OFFSET); +// //use in manual ack +// rmqMessageExt.setQueueId(queueId); +// rmqMessageExt.setQueueOffset(queueOffset); +// +// for (String key : userProperties.stringPropertyNames()) { +// MessageAccessor.putProperty(rmqMessageExt, key, userProperties.getProperty(key)); +// } +// +// //System headers has a high priority +// for (String key : systemProperties.stringPropertyNames()) { +// MessageAccessor.putProperty(rmqMessageExt, key, systemProperties.getProperty(key)); +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return rmqMessageExt; +// +// } +// +// public static boolean isOMSHeader(String value) { +// for (Field field : OMSBuiltinKeys.class.getDeclaredFields()) { +// try { +// if (field.get(OMSBuiltinKeys.class).equals(value)) { +// return true; +// } +// } catch (IllegalAccessException e) { +// return false; +// } +// } +// return false; +// } +// +// /** +// * Convert a RocketMQ SEND_OK SendResult instance to a OMS SendResult. +// * +// * @param rmqResult RocketMQ result +// * @return send result +// */ +// public static SendResult sendResultConvert(org.apache.rocketmq.client.producer.SendResult rmqResult) { +// SendResult sendResult = new SendResult(); +// sendResult.setTopic(rmqResult.getMessageQueue().getTopic()); +// sendResult.setMessageId(rmqResult.getMsgId()); +// return sendResult; +// } +// +//// public static KeyValue buildKeyValue(KeyValue... keyValues) { +//// KeyValue keyValue = OMS.newKeyValue(); +//// for (KeyValue properties : keyValues) { +//// for (String key : properties.keySet()) { +//// keyValue.put(key, properties.getString(key)); +//// } +//// } +//// return keyValue; +//// } +// +// /** +// * Returns an iterator that cycles indefinitely over the elements of {@code Iterable}. +// * +// * @param Target type +// * @return Iterator +// */ +// public static Iterator cycle(final Iterable iterable) { +// return new Iterator() { +// Iterator iterator = new Iterator() { +// @Override +// public synchronized boolean hasNext() { +// return false; +// } +// +// @Override +// public synchronized T next() { +// throw new NoSuchElementException(); +// } +// +// @Override +// public synchronized void remove() { +// //Ignore +// } +// }; +// +// @Override +// public synchronized boolean hasNext() { +// return iterator.hasNext() || iterable.iterator().hasNext(); +// } +// +// @Override +// public synchronized T next() { +// if (!iterator.hasNext()) { +// iterator = iterable.iterator(); +// if (!iterator.hasNext()) { +// throw new NoSuchElementException(); +// } +// } +// return iterator.next(); +// } +// +// @Override +// public synchronized void remove() { +// iterator.remove(); +// } +// }; // } - - /** - * Returns an iterator that cycles indefinitely over the elements of {@code Iterable}. - * - * @param Target type - * @return Iterator - */ - public static Iterator cycle(final Iterable iterable) { - return new Iterator() { - Iterator iterator = new Iterator() { - @Override - public synchronized boolean hasNext() { - return false; - } - - @Override - public synchronized T next() { - throw new NoSuchElementException(); - } - - @Override - public synchronized void remove() { - //Ignore - } - }; - - @Override - public synchronized boolean hasNext() { - return iterator.hasNext() || iterable.iterator().hasNext(); - } - - @Override - public synchronized T next() { - if (!iterator.hasNext()) { - iterator = iterable.iterator(); - if (!iterator.hasNext()) { - throw new NoSuchElementException(); - } - } - return iterator.next(); - } - - @Override - public synchronized void remove() { - iterator.remove(); - } - }; - } } diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.consumer.MeshMQPushConsumer b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.consumer.Consumer similarity index 100% rename from eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.consumer.MeshMQPushConsumer rename to eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.consumer.Consumer diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.producer.MeshMQProducer b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.producer.Producer similarity index 100% rename from eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.producer.MeshMQProducer rename to eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.producer.Producer diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/rocketmq-client.properties b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/rocketmq-client.properties index 1261f30e2c..8e0822ad36 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/rocketmq-client.properties +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/rocketmq-client.properties @@ -16,3 +16,6 @@ # #######################rocketmq-client################## eventMesh.server.rocketmq.namesrvAddr=127.0.0.1:9876;127.0.0.1:9876 +eventMesh.server.rocketmq.cluster=DefaultCluster +eventMesh.server.rocketmq.accessKey=******** +eventMesh.server.rocketmq.secretKey=******** diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWrapperTest.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWrapperTest.java new file mode 100644 index 0000000000..6d25baf7cf --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWrapperTest.java @@ -0,0 +1,30 @@ +/* + * Licensed 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.eventmesh.connector.rocketmq.config; + +import org.junit.Assert; +import org.junit.Test; + +public class ConfigurationWrapperTest { + + @Test + public void getProp() { + String namesrcAddr = ConfigurationWrapper.getProp("eventMesh.server.rocketmq.namesrvAddr"); + Assert.assertNotNull(namesrcAddr); + } +} \ No newline at end of file diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/eventmesh/producer/DefaultProducerImplTest.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/eventmesh/producer/DefaultProducerImplTest.java new file mode 100644 index 0000000000..16ff257b79 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/eventmesh/producer/DefaultProducerImplTest.java @@ -0,0 +1,63 @@ +/* + * Licensed 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.eventmesh.producer; + + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.eventmesh.api.producer.MeshMQProducer; +import org.apache.eventmesh.connector.rocketmq.producer.RocketMQProducerImpl; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import io.openmessaging.api.exception.OMSRuntimeException; + +public class DefaultProducerImplTest { + + @Before + public void before() {} + + + @After + public void after() { + //TBD:Remove topic + } + + @Test + public void testCreate_EmptyTopic() { + MeshMQProducer meshPub = new RocketMQProducerImpl(); + try { + meshPub.createTopic(" "); + } catch (OMSRuntimeException e) { + assertThat(e.getMessage()).isEqualToIgnoringWhitespace("RocketMQ can not create topic"); + } + } + + @Test + public void testCreate_NullTopic() { + MeshMQProducer meshPub = new RocketMQProducerImpl(); + try { + meshPub.createTopic(null); + } catch (OMSRuntimeException e) { + String errorMessage = e.getMessage(); + assertThat(errorMessage).isEqualTo("RocketMQ can not create topic null"); + } + } +} \ No newline at end of file diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/consumer/PushConsumerImplTest.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/consumer/PushConsumerImplTest.java index 86a5ffda22..4f67de7573 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/consumer/PushConsumerImplTest.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/consumer/PushConsumerImplTest.java @@ -19,25 +19,19 @@ import static org.assertj.core.api.Assertions.assertThat; -import java.lang.reflect.Field; -import java.util.Collections; -import java.util.Properties; - -import io.openmessaging.api.AsyncConsumeContext; -import io.openmessaging.api.AsyncMessageListener; -import io.openmessaging.api.Consumer; -import io.openmessaging.api.Message; -import io.openmessaging.api.MessagingAccessPoint; -import io.openmessaging.api.OMS; -import io.openmessaging.api.OMSBuiltinKeys; - +import org.apache.eventmesh.api.EventListener; import org.apache.eventmesh.api.EventMeshAction; -import org.apache.eventmesh.api.EventMeshAsyncConsumeContext; import org.apache.eventmesh.connector.rocketmq.consumer.PushConsumerImpl; import org.apache.eventmesh.connector.rocketmq.domain.NonStandardKeys; + import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; import org.apache.rocketmq.common.message.MessageExt; + +import java.lang.reflect.Field; +import java.util.Collections; +import java.util.Properties; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -46,9 +40,11 @@ import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; +import io.cloudevents.CloudEvent; + @RunWith(MockitoJUnitRunner.class) public class PushConsumerImplTest { - private Consumer consumer; + private PushConsumerImpl consumer; @Mock private DefaultMQPushConsumer rocketmqPushConsumer; @@ -56,15 +52,16 @@ public class PushConsumerImplTest { @Before public void before() throws Exception { Properties consumerProp = new Properties(); - consumerProp.setProperty(OMSBuiltinKeys.DRIVER_IMPL, "org.apache.eventmesh.connector.rocketmq.MessagingAccessPointImpl"); +// consumerProp.setProperty(OMSBuiltinKeys.DRIVER_IMPL, +// "org.apache.eventmesh.connector.rocketmq.MessagingAccessPointImpl"); consumerProp.setProperty("access_points", "IP1:9876,IP2:9876"); - final MessagingAccessPoint messagingAccessPoint = OMS.builder().build(consumerProp);//.endpoint("oms:rocketmq://IP1:9876,IP2:9876/namespace").build(config); + //final MessagingAccessPoint messagingAccessPoint = OMS.builder().build(consumerProp);//.endpoint("oms:rocketmq://IP1:9876,IP2:9876/namespace").build(config); consumerProp.setProperty("message.model", "CLUSTERING"); //Properties consumerProp = new Properties(); consumerProp.put("CONSUMER_ID", "TestGroup"); - consumer = messagingAccessPoint.createConsumer(consumerProp); + consumer = new PushConsumerImpl(consumerProp); Field field = PushConsumerImpl.class.getDeclaredField("rocketmqPushConsumer"); @@ -84,23 +81,24 @@ public void after() throws Exception { @Test public void testConsumeMessage() { - final byte[] testBody = new byte[]{'a', 'b'}; + final byte[] testBody = new byte[] {'a', 'b'}; MessageExt consumedMsg = new MessageExt(); consumedMsg.setMsgId("NewMsgId"); consumedMsg.setBody(testBody); consumedMsg.putUserProperty(NonStandardKeys.MESSAGE_DESTINATION, "TOPIC"); consumedMsg.setTopic("HELLO_QUEUE"); - consumer.subscribe("HELLO_QUEUE", "*", new AsyncMessageListener() { + consumer.subscribe("HELLO_QUEUE", "*", new EventListener() { + @Override - public void consume(Message message, AsyncConsumeContext context) { - assertThat(message.getSystemProperties("MESSAGE_ID")).isEqualTo("NewMsgId"); - assertThat(message.getBody()).isEqualTo(testBody); - ((EventMeshAsyncConsumeContext)context).commit(EventMeshAction.CommitMessage); + public void consume(CloudEvent cloudEvent, org.apache.eventmesh.api.AsyncConsumeContext context) { + assertThat(cloudEvent.getExtension("MESSAGE_ID")).isEqualTo("NewMsgId"); + assertThat(cloudEvent.getData()).isEqualTo(testBody); + context.commit(EventMeshAction.CommitMessage); } }); ((MessageListenerConcurrently) rocketmqPushConsumer - .getMessageListener()).consumeMessage(Collections.singletonList(consumedMsg), null); + .getMessageListener()).consumeMessage(Collections.singletonList(consumedMsg), null); } diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/producer/ProducerImplTest.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/producer/ProducerImplTest.java index 83d55710f0..27e0c69f29 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/producer/ProducerImplTest.java +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/producer/ProducerImplTest.java @@ -21,16 +21,10 @@ import static org.assertj.core.api.Fail.failBecauseExceptionWasNotThrown; import static org.mockito.ArgumentMatchers.any; -import java.lang.reflect.Field; -import java.util.Properties; - -import io.openmessaging.api.MessagingAccessPoint; -import io.openmessaging.api.OMS; -import io.openmessaging.api.OMSBuiltinKeys; -import io.openmessaging.api.Producer; -import io.openmessaging.api.exception.OMSRuntimeException; +import org.apache.eventmesh.api.exception.ConnectorRuntimeException; +import org.apache.eventmesh.connector.rocketmq.producer.AbstractProducer; +import org.apache.eventmesh.connector.rocketmq.producer.ProducerImpl; -import org.apache.eventmesh.connector.rocketmq.producer.AbstractOMSProducer; import org.apache.rocketmq.client.exception.MQBrokerException; import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl; @@ -41,6 +35,11 @@ import org.apache.rocketmq.common.message.Message; import org.apache.rocketmq.common.message.MessageQueue; import org.apache.rocketmq.remoting.exception.RemotingException; + +import java.lang.reflect.Field; +import java.net.URI; +import java.util.Properties; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -49,9 +48,12 @@ import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; + @RunWith(MockitoJUnitRunner.class) public class ProducerImplTest { - private Producer producer; + private ProducerImpl producer; @Mock private DefaultMQProducer rocketmqProducer; @@ -59,26 +61,20 @@ public class ProducerImplTest { @Before public void before() throws NoSuchFieldException, IllegalAccessException { Properties config = new Properties(); - config.setProperty(OMSBuiltinKeys.DRIVER_IMPL, "org.apache.eventmesh.connector.rocketmq.MessagingAccessPointImpl"); config.setProperty("access_points", "IP1:9876,IP2:9876"); - final MessagingAccessPoint messagingAccessPoint = OMS.builder().build(config);//.endpoint("oms:rocketmq://IP1:9876,IP2:9876/namespace").build(config); - producer = messagingAccessPoint.createProducer(config); + producer = new ProducerImpl(config); - Field field = AbstractOMSProducer.class.getDeclaredField("rocketmqProducer"); + Field field = AbstractProducer.class.getDeclaredField("rocketmqProducer"); field.setAccessible(true); field.set(producer, rocketmqProducer); -// messagingAccessPoint.startup(); producer.start(); } - @After - public void after() throws NoSuchFieldException, IllegalAccessException { - + public void after() { producer.shutdown(); - } @Test @@ -97,39 +93,22 @@ public void testSend_OK() throws InterruptedException, RemotingException, MQClie Mockito.when(rocketmqProducer.getDefaultMQProducerImpl()).thenReturn(defaultMQProducerImpl); - io.openmessaging.api.Message message = new io.openmessaging.api.Message("HELLO_TOPIC", "", new byte[]{'a'}); - io.openmessaging.api.SendResult omsResult = - producer.send(message); + CloudEvent cloudEvent = CloudEventBuilder.v1() + .withId("id1") + .withSource(URI.create("https://github.com/cloudevents/*****")) + .withType("producer.example") + .withSubject("HELLO_TOPIC") + .withData("hello world".getBytes()) + .build(); + org.apache.eventmesh.api.SendResult result = + producer.send(cloudEvent); - assertThat(omsResult.getMessageId()).isEqualTo("TestMsgID"); + assertThat(result.getMessageId()).isEqualTo("TestMsgID"); Mockito.verify(rocketmqProducer).getDefaultMQProducerImpl(); Mockito.verify(rocketmqProducer).send(any(Message.class)); } -// @Test -// public void testSend_Not_OK() throws InterruptedException, RemotingException, MQClientException, MQBrokerException { -// SendResult sendResult = new SendResult(); -// sendResult.setSendStatus(SendStatus.FLUSH_DISK_TIMEOUT); -// MessageQueue messageQueue = new MessageQueue("HELLO_TOPIC", "testBroker", 0); -// sendResult.setMessageQueue(messageQueue); -// -// when(rocketmqProducer.send(any(Message.class))).thenReturn(sendResult); -// -// DefaultMQProducer defaultMQProducer =new DefaultMQProducer("testGroup"); -// DefaultMQProducerImpl defaultMQProducerImpl = new DefaultMQProducerImpl(defaultMQProducer); -// defaultMQProducerImpl.setServiceState(ServiceState.RUNNING); -// when(rocketmqProducer.getDefaultMQProducerImpl()).thenReturn(defaultMQProducerImpl); -// -// try { -// io.openmessaging.api.Message message = new io.openmessaging.api.Message("HELLO_TOPIC", "", new byte[] {'a'}); -// producer.send(message); -// failBecauseExceptionWasNotThrown(OMSRuntimeException.class); -// } catch (Exception e) { -// assertThat(e).hasMessageContaining("Send message to RocketMQ broker failed."); -// } -// } - @Test public void testSend_WithException() throws InterruptedException, RemotingException, MQClientException, MQBrokerException { DefaultMQProducer defaultMQProducer = new DefaultMQProducer("testGroup"); @@ -140,9 +119,15 @@ public void testSend_WithException() throws InterruptedException, RemotingExcept Mockito.when(rocketmqProducer.send(any(Message.class))).thenThrow(exception); try { - io.openmessaging.api.Message message = new io.openmessaging.api.Message("HELLO_TOPIC", "", new byte[]{'a'}); - producer.send(message); - failBecauseExceptionWasNotThrown(OMSRuntimeException.class); + CloudEvent cloudEvent = CloudEventBuilder.v1() + .withId("id1") + .withSource(URI.create("https://github.com/cloudevents/*****")) + .withType("producer.example") + .withSubject("HELLO_TOPIC") + .withData(new byte[]{'a'}) + .build(); + producer.send(cloudEvent); + failBecauseExceptionWasNotThrown(ConnectorRuntimeException.class); } catch (Exception e) { assertThat(e).hasMessageContaining("Send message to RocketMQ broker failed."); } diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/org.apache.io.openmessaging.MessagingAccessPoint b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/org.apache.io.openmessaging.MessagingAccessPoint deleted file mode 100644 index e326c919c7..0000000000 --- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/org.apache.io.openmessaging.MessagingAccessPoint +++ /dev/null @@ -1,20 +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. -# - -org.apache.eventmesh.connector.rocketmq.MessagingAccessPointImpl \ No newline at end of file diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/resources/rocketmq-client.properties b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/resources/rocketmq-client.properties new file mode 100644 index 0000000000..1261f30e2c --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/resources/rocketmq-client.properties @@ -0,0 +1,18 @@ +# +# Licensed 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. +# +#######################rocketmq-client################## +eventMesh.server.rocketmq.namesrvAddr=127.0.0.1:9876;127.0.0.1:9876 diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/build.gradle b/eventmesh-connector-plugin/eventmesh-connector-standalone/build.gradle index 6152c89028..e857140355 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/build.gradle +++ b/eventmesh-connector-plugin/eventmesh-connector-standalone/build.gradle @@ -16,9 +16,7 @@ */ dependencies { - compileOnly project(":eventmesh-common") - compileOnly project(":eventmesh-connector-plugin:eventmesh-connector-api") + implementation project(":eventmesh-common") + implementation project(":eventmesh-connector-plugin:eventmesh-connector-api") - testImplementation project(":eventmesh-connector-plugin:eventmesh-connector-api") - testImplementation project(":eventmesh-common") } \ No newline at end of file diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/MessagingAccessPointImpl.java b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/MessagingAccessPointImpl.java deleted file mode 100644 index 6701e81c80..0000000000 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/MessagingAccessPointImpl.java +++ /dev/null @@ -1,91 +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 org.apache.eventmesh.connector.standalone; - -import io.openmessaging.api.Consumer; -import io.openmessaging.api.MessagingAccessPoint; -import io.openmessaging.api.Producer; -import io.openmessaging.api.PullConsumer; -import io.openmessaging.api.batch.BatchConsumer; -import io.openmessaging.api.order.OrderConsumer; -import io.openmessaging.api.order.OrderProducer; -import io.openmessaging.api.transaction.LocalTransactionChecker; -import io.openmessaging.api.transaction.TransactionProducer; -import org.apache.eventmesh.connector.standalone.consumer.StandaloneConsumer; -import org.apache.eventmesh.connector.standalone.producer.StandaloneProducer; - -import java.util.Properties; - -public class MessagingAccessPointImpl implements MessagingAccessPoint { - - private Properties accessPointProperties; - - public MessagingAccessPointImpl(Properties accessPointProperties) { - this.accessPointProperties = accessPointProperties; - } - - @Override - public String version() { - return null; - } - - @Override - public Properties attributes() { - return accessPointProperties; - } - - @Override - public Producer createProducer(Properties properties) { - return new StandaloneProducer(properties); - } - - @Override - public OrderProducer createOrderProducer(Properties properties) { - return null; - } - - @Override - public TransactionProducer createTransactionProducer(Properties properties, LocalTransactionChecker checker) { - return null; - } - - @Override - public TransactionProducer createTransactionProducer(Properties properties) { - return null; - } - - @Override - public Consumer createConsumer(Properties properties) { - return new StandaloneConsumer(properties); - } - - @Override - public PullConsumer createPullConsumer(Properties properties) { - return null; - } - - @Override - public BatchConsumer createBatchConsumer(Properties properties) { - return null; - } - - @Override - public OrderConsumer createOrderedConsumer(Properties properties) { - return null; - } -} diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/MessageQueue.java b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/MessageQueue.java index 629975e44b..6936a1b6d3 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/MessageQueue.java +++ b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/MessageQueue.java @@ -81,7 +81,7 @@ public void put(MessageEntity messageEntity) throws InterruptedException { * Get the first message at this queue, waiting for the message is available if the queue is empty, * this method will not remove the message * - * @return + * @return MessageEntity * @throws InterruptedException */ public MessageEntity take() throws InterruptedException { @@ -100,7 +100,7 @@ public MessageEntity take() throws InterruptedException { /** * Get the first message at this queue, if the queue is empty return null immediately * - * @return + * @return MessageEntity */ public MessageEntity peek() { ReentrantLock lock = this.lock; @@ -115,7 +115,7 @@ public MessageEntity peek() { /** * Get the head in this queue * - * @return + * @return MessageEntity */ public MessageEntity getHead() { return peek(); @@ -124,7 +124,7 @@ public MessageEntity getHead() { /** * Get the tail in this queue * - * @return + * @return MessageEntity */ public MessageEntity getTail() { ReentrantLock lock = this.lock; @@ -148,7 +148,7 @@ public MessageEntity getTail() { * and calculate the index of this offset * * @param offset - * @return + * @return MessageEntity */ public MessageEntity getByOffset(long offset) { ReentrantLock lock = this.lock; diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/StandaloneBroker.java b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/StandaloneBroker.java index 8f35c3a789..822d1c09ef 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/StandaloneBroker.java +++ b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/StandaloneBroker.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.connector.standalone.broker; -import io.openmessaging.api.Message; +import io.cloudevents.CloudEvent; import org.apache.commons.lang3.tuple.Pair; import org.apache.eventmesh.connector.standalone.broker.model.MessageEntity; import org.apache.eventmesh.connector.standalone.broker.model.TopicMetadata; @@ -53,7 +53,7 @@ public static StandaloneBroker getInstance() { * @param message message * @throws InterruptedException */ - public MessageEntity putMessage(String topicName, Message message) throws InterruptedException { + public MessageEntity putMessage(String topicName, CloudEvent message) throws InterruptedException { Pair pair = createTopicIfAbsent(topicName); AtomicLong topicOffset = pair.getRight(); MessageQueue messageQueue = pair.getLeft(); @@ -70,7 +70,7 @@ public MessageEntity putMessage(String topicName, Message message) throws Interr * * @param topicName */ - public Message takeMessage(String topicName) throws InterruptedException { + public CloudEvent takeMessage(String topicName) throws InterruptedException { TopicMetadata topicMetadata = new TopicMetadata(topicName); return messageContainer.computeIfAbsent(topicMetadata, k -> new MessageQueue()).take().getMessage(); } @@ -80,7 +80,7 @@ public Message takeMessage(String topicName) throws InterruptedException { * * @param topicName */ - public Message getMessage(String topicName) { + public CloudEvent getMessage(String topicName) { TopicMetadata topicMetadata = new TopicMetadata(topicName); MessageEntity head = messageContainer.computeIfAbsent(topicMetadata, k -> new MessageQueue()).getHead(); if (head == null) { @@ -94,9 +94,9 @@ public Message getMessage(String topicName) { * * @param topicName topic name * @param offset offset - * @return + * @return CloudEvent */ - public Message getMessage(String topicName, long offset) { + public CloudEvent getMessage(String topicName, long offset) { TopicMetadata topicMetadata = new TopicMetadata(topicName); MessageEntity messageEntity = messageContainer.computeIfAbsent(topicMetadata, k -> new MessageQueue()).getByOffset(offset); if (messageEntity == null) { diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/model/MessageEntity.java b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/model/MessageEntity.java index d816891d86..dd7468f03b 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/model/MessageEntity.java +++ b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/model/MessageEntity.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.connector.standalone.broker.model; -import io.openmessaging.api.Message; +import io.cloudevents.CloudEvent; import java.io.Serializable; @@ -25,13 +25,13 @@ public class MessageEntity implements Serializable { private TopicMetadata topicMetadata; - private Message message; + private CloudEvent message; private long offset; private long createTimeMills; - public MessageEntity(TopicMetadata topicMetadata, Message message, long offset, long currentTimeMills) { + public MessageEntity(TopicMetadata topicMetadata, CloudEvent message, long offset, long currentTimeMills) { this.topicMetadata = topicMetadata; this.message = message; this.offset = offset; @@ -46,11 +46,11 @@ public void setTopicMetadata(TopicMetadata topicMetadata) { this.topicMetadata = topicMetadata; } - public Message getMessage() { + public CloudEvent getMessage() { return message; } - public void setMessage(Message message) { + public void setMessage(CloudEvent message) { this.message = message; } diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/task/SubScribeTask.java b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/task/SubScribeTask.java index 373915def8..f5058c111c 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/task/SubScribeTask.java +++ b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/broker/task/SubScribeTask.java @@ -17,24 +17,24 @@ package org.apache.eventmesh.connector.standalone.broker.task; -import io.openmessaging.api.AsyncMessageListener; -import io.openmessaging.api.Message; +import org.apache.eventmesh.api.EventListener; import org.apache.eventmesh.api.EventMeshAction; import org.apache.eventmesh.api.EventMeshAsyncConsumeContext; import org.apache.eventmesh.connector.standalone.broker.StandaloneBroker; + +import java.util.concurrent.atomic.AtomicInteger; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; +import io.cloudevents.CloudEvent; public class SubScribeTask implements Runnable { - private String topicName; - private StandaloneBroker standaloneBroker; - private AsyncMessageListener listener; - private volatile boolean isRunning; + private String topicName; + private StandaloneBroker standaloneBroker; + private EventListener listener; + private volatile boolean isRunning; private AtomicInteger offset; @@ -42,7 +42,7 @@ public class SubScribeTask implements Runnable { public SubScribeTask(String topicName, StandaloneBroker standaloneBroker, - AsyncMessageListener listener) { + EventListener listener) { this.topicName = topicName; this.standaloneBroker = standaloneBroker; this.listener = listener; @@ -55,13 +55,18 @@ public void run() { try { logger.debug("execute subscribe task, topic: {}, offset: {}", topicName, offset); if (offset == null) { - Message message = standaloneBroker.getMessage(topicName); + CloudEvent message = standaloneBroker.getMessage(topicName); if (message != null) { - offset = new AtomicInteger((int) message.getOffset()); + if (message.getExtension("offset") != null) { + offset = new AtomicInteger((int) message.getExtension("offset")); + } else { + offset = new AtomicInteger(0); + } + } } if (offset != null) { - Message message = standaloneBroker.getMessage(topicName, offset.get()); + CloudEvent message = standaloneBroker.getMessage(topicName, offset.get()); if (message != null) { EventMeshAsyncConsumeContext consumeContext = new EventMeshAsyncConsumeContext() { @Override @@ -69,7 +74,8 @@ public void commit(EventMeshAction action) { switch (action) { case CommitMessage: // update offset - logger.info("message commit, topic: {}, current offset:{}", topicName, offset.get()); + logger.info("message commit, topic: {}, current offset:{}", topicName, + offset.get()); break; case ReconsumeLater: // don't update offset @@ -77,7 +83,8 @@ public void commit(EventMeshAction action) { case ManualAck: // update offset offset.incrementAndGet(); - logger.info("message ack, topic: {}, current offset:{}", topicName, offset.get()); + logger + .info("message ack, topic: {}, current offset:{}", topicName, offset.get()); break; default: @@ -89,13 +96,14 @@ public void commit(EventMeshAction action) { } } catch (Exception ex) { - logger.error("consumer error, topic: {}, offset: {}", topicName, offset == null ? null : offset.get(), ex); + logger.error("consumer error, topic: {}, offset: {}", topicName, offset == null ? null : offset.get(), + ex); } try { Thread.sleep(1000); } catch (InterruptedException e) { logger.error("Thread is interrupted, topic: {}, offset: {} thread name: {}", - topicName, offset == null ? null : offset.get(), Thread.currentThread().getName(), e); + topicName, offset == null ? null : offset.get(), Thread.currentThread().getName(), e); Thread.currentThread().interrupt(); } } diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/consumer/StandaloneConsumer.java b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/consumer/StandaloneConsumer.java index d206cea5ee..5a1837964b 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/consumer/StandaloneConsumer.java +++ b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/consumer/StandaloneConsumer.java @@ -17,23 +17,21 @@ package org.apache.eventmesh.connector.standalone.consumer; -import io.openmessaging.api.AsyncGenericMessageListener; -import io.openmessaging.api.AsyncMessageListener; -import io.openmessaging.api.Consumer; -import io.openmessaging.api.GenericMessageListener; -import io.openmessaging.api.Message; -import io.openmessaging.api.MessageListener; -import io.openmessaging.api.MessageSelector; +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.api.EventListener; +import org.apache.eventmesh.api.consumer.Consumer; import org.apache.eventmesh.common.ThreadPoolFactory; import org.apache.eventmesh.connector.standalone.broker.StandaloneBroker; import org.apache.eventmesh.connector.standalone.broker.model.TopicMetadata; import org.apache.eventmesh.connector.standalone.broker.task.SubScribeTask; +import java.util.List; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Predicate; + +import io.cloudevents.CloudEvent; public class StandaloneConsumer implements Consumer { @@ -50,30 +48,49 @@ public StandaloneConsumer(Properties properties) { this.subscribeTaskTable = new ConcurrentHashMap<>(16); this.isStarted = new AtomicBoolean(false); this.consumeExecutorService = ThreadPoolFactory.createThreadPoolExecutor( - Runtime.getRuntime().availableProcessors() * 2, - Runtime.getRuntime().availableProcessors() * 2, - "StandaloneConsumerThread" + Runtime.getRuntime().availableProcessors() * 2, + Runtime.getRuntime().availableProcessors() * 2, + "StandaloneConsumerThread" ); } @Override - public void subscribe(String topic, String subExpression, MessageListener listener) { + public boolean isStarted() { + return isStarted.get(); } @Override - public void subscribe(String topic, MessageSelector selector, MessageListener listener) { + public boolean isClosed() { + return !isStarted.get(); } @Override - public void subscribe(String topic, String subExpression, GenericMessageListener listener) { + public void start() { + isStarted.compareAndSet(false, true); } @Override - public void subscribe(String topic, MessageSelector selector, GenericMessageListener listener) { + public void shutdown() { + isStarted.compareAndSet(true, false); + subscribeTaskTable.forEach(((topic, subScribeTask) -> subScribeTask.shutdown())); + subscribeTaskTable.clear(); + } + + @Override + public void init(Properties keyValue) throws Exception { + } @Override - public void subscribe(String topic, String subExpression, AsyncMessageListener listener) { + public void updateOffset(List cloudEvents, AbstractContext context) { + cloudEvents.forEach(cloudEvent -> standaloneBroker.updateOffset( + new TopicMetadata(cloudEvent.getSubject()), (Long) cloudEvent.getExtension("offset")) + ); + + } + + @Override + public void subscribe(String topic, EventListener listener) throws Exception { if (listener == null) { throw new IllegalArgumentException("listener cannot be null"); } @@ -88,18 +105,6 @@ public void subscribe(String topic, String subExpression, AsyncMessageListener l } } - @Override - public void subscribe(String topic, MessageSelector selector, AsyncMessageListener listener) { - } - - @Override - public void subscribe(String topic, String subExpression, AsyncGenericMessageListener listener) { - } - - @Override - public void subscribe(String topic, MessageSelector selector, AsyncGenericMessageListener listener) { - } - @Override public void unsubscribe(String topic) { if (!subscribeTaskTable.containsKey(topic)) { @@ -111,35 +116,4 @@ public void unsubscribe(String topic) { subscribeTaskTable.remove(topic); } } - - @Override - public void updateCredential(Properties credentialProperties) { - - } - - @Override - public boolean isStarted() { - return isStarted.get(); - } - - @Override - public boolean isClosed() { - return !isStarted.get(); - } - - @Override - public void start() { - isStarted.compareAndSet(false, true); - } - - @Override - public void shutdown() { - isStarted.compareAndSet(true, false); - subscribeTaskTable.forEach(((topic, subScribeTask) -> subScribeTask.shutdown())); - subscribeTaskTable.clear(); - } - - public void updateOffset(Message message) { - standaloneBroker.updateOffset(new TopicMetadata(message.getTopic()), message.getOffset()); - } } \ No newline at end of file diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/consumer/StandaloneConsumerAdaptor.java b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/consumer/StandaloneConsumerAdaptor.java new file mode 100644 index 0000000000..716b4a21d3 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/consumer/StandaloneConsumerAdaptor.java @@ -0,0 +1,172 @@ +/* + * Licensed 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.eventmesh.connector.standalone.consumer; + +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.api.EventListener; +import org.apache.eventmesh.api.consumer.Consumer; + +import java.util.List; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.cloudevents.CloudEvent; + +public class StandaloneConsumerAdaptor implements Consumer { + + private final Logger logger = LoggerFactory.getLogger(StandaloneConsumerAdaptor.class); + + private StandaloneConsumer consumer; + + public StandaloneConsumerAdaptor() { + } + + @Override + public boolean isStarted() { + return consumer.isStarted(); + } + + @Override + public boolean isClosed() { + return consumer.isClosed(); + } + + @Override + public void start() { + consumer.start(); + } + + @Override + public void shutdown() { + consumer.shutdown(); + } + + @Override + public void init(Properties keyValue) throws Exception { + consumer = new StandaloneConsumer(keyValue); + } + + @Override + public void updateOffset(List cloudEvents, AbstractContext context) { + consumer.updateOffset(cloudEvents, context); + } + + @Override + public void subscribe(String topic, EventListener listener) throws Exception { + consumer.subscribe(topic, listener); + } + + @Override + public void unsubscribe(String topic) { + consumer.unsubscribe(topic); + } + +// @Override +// public void init(Properties keyValue) throws Exception { +// String producerGroup = keyValue.getProperty("producerGroup"); +// +// MessagingAccessPointImpl messagingAccessPoint = new MessagingAccessPointImpl(keyValue); +// consumer = (StandaloneConsumer) messagingAccessPoint.createConsumer(keyValue); +// +// } +// +// @Override +// public void updateOffset(List msgs, AbstractContext context) { +// for(Message message : msgs) { +// consumer.updateOffset(message); +// } +// } +// +// @Override +// public void subscribe(String topic, AsyncMessageListener listener) throws Exception { +// // todo: support subExpression +// consumer.subscribe(topic, "*", listener); +// } +// +// @Override +// public void unsubscribe(String topic) { +// consumer.unsubscribe(topic); +// } +// +// @Override +// public void subscribe(String topic, String subExpression, MessageListener listener) { +// throw new UnsupportedOperationException("not supported yet"); +// } +// +// @Override +// public void subscribe(String topic, MessageSelector selector, MessageListener listener) { +// throw new UnsupportedOperationException("not supported yet"); +// } +// +// @Override +// public void subscribe(String topic, String subExpression, GenericMessageListener listener) { +// throw new UnsupportedOperationException("not supported yet"); +// } +// +// @Override +// public void subscribe(String topic, MessageSelector selector, GenericMessageListener listener) { +// throw new UnsupportedOperationException("not supported yet"); +// } +// +// @Override +// public void subscribe(String topic, String subExpression, AsyncMessageListener listener) { +// throw new UnsupportedOperationException("not supported yet"); +// } +// +// @Override +// public void subscribe(String topic, MessageSelector selector, AsyncMessageListener listener) { +// throw new UnsupportedOperationException("not supported yet"); +// } +// +// @Override +// public void subscribe(String topic, String subExpression, AsyncGenericMessageListener listener) { +// throw new UnsupportedOperationException("not supported yet"); +// } +// +// @Override +// public void subscribe(String topic, MessageSelector selector, AsyncGenericMessageListener listener) { +// throw new UnsupportedOperationException("not supported yet"); +// } +// +// @Override +// public void updateCredential(Properties credentialProperties) { +// +// } +// +// @Override +// public boolean isStarted() { +// return consumer.isStarted(); +// } +// +// @Override +// public boolean isClosed() { +// return consumer.isClosed(); +// } +// +// @Override +// public void start() { +// consumer.start(); +// } +// +// @Override +// public void shutdown() { +// consumer.shutdown(); +// } +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/consumer/StandaloneMeshMQPushConsumerAdaptor.java b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/consumer/StandaloneMeshMQPushConsumerAdaptor.java deleted file mode 100644 index 3bd4ec9167..0000000000 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/consumer/StandaloneMeshMQPushConsumerAdaptor.java +++ /dev/null @@ -1,135 +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 org.apache.eventmesh.connector.standalone.consumer; - -import io.openmessaging.api.AsyncGenericMessageListener; -import io.openmessaging.api.AsyncMessageListener; -import io.openmessaging.api.GenericMessageListener; -import io.openmessaging.api.Message; -import io.openmessaging.api.MessageListener; -import io.openmessaging.api.MessageSelector; -import org.apache.eventmesh.api.AbstractContext; -import org.apache.eventmesh.api.consumer.MeshMQPushConsumer; -import org.apache.eventmesh.connector.standalone.MessagingAccessPointImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; -import java.util.Properties; - -public class StandaloneMeshMQPushConsumerAdaptor implements MeshMQPushConsumer { - - private final Logger logger = LoggerFactory.getLogger(StandaloneMeshMQPushConsumerAdaptor.class); - - private StandaloneConsumer consumer; - - public StandaloneMeshMQPushConsumerAdaptor() { - } - - @Override - public void init(Properties keyValue) throws Exception { - String producerGroup = keyValue.getProperty("producerGroup"); - - MessagingAccessPointImpl messagingAccessPoint = new MessagingAccessPointImpl(keyValue); - consumer = (StandaloneConsumer) messagingAccessPoint.createConsumer(keyValue); - - } - - @Override - public void updateOffset(List msgs, AbstractContext context) { - for(Message message : msgs) { - consumer.updateOffset(message); - } - } - - @Override - public void subscribe(String topic, AsyncMessageListener listener) throws Exception { - // todo: support subExpression - consumer.subscribe(topic, "*", listener); - } - - @Override - public void unsubscribe(String topic) { - consumer.unsubscribe(topic); - } - - @Override - public void subscribe(String topic, String subExpression, MessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, MessageSelector selector, MessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, String subExpression, GenericMessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, MessageSelector selector, GenericMessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, String subExpression, AsyncMessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, MessageSelector selector, AsyncMessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, String subExpression, AsyncGenericMessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void subscribe(String topic, MessageSelector selector, AsyncGenericMessageListener listener) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void updateCredential(Properties credentialProperties) { - - } - - @Override - public boolean isStarted() { - return consumer.isStarted(); - } - - @Override - public boolean isClosed() { - return consumer.isClosed(); - } - - @Override - public void start() { - consumer.start(); - } - - @Override - public void shutdown() { - consumer.shutdown(); - } -} diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/producer/StandaloneMeshMQProducerAdaptor.java b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/producer/StandaloneMeshMQProducerAdaptor.java deleted file mode 100644 index fb632c7c5c..0000000000 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/producer/StandaloneMeshMQProducerAdaptor.java +++ /dev/null @@ -1,125 +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 org.apache.eventmesh.connector.standalone.producer; - -import io.openmessaging.api.Message; -import io.openmessaging.api.MessageBuilder; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; -import org.apache.eventmesh.api.RRCallback; -import org.apache.eventmesh.api.producer.MeshMQProducer; -import org.apache.eventmesh.connector.standalone.MessagingAccessPointImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Properties; -import java.util.concurrent.ExecutorService; - -public class StandaloneMeshMQProducerAdaptor implements MeshMQProducer { - - private final Logger logger = LoggerFactory.getLogger(StandaloneMeshMQProducerAdaptor.class); - - private StandaloneProducer standaloneProducer; - - public StandaloneMeshMQProducerAdaptor() { - } - - @Override - public void init(Properties properties) throws Exception { - MessagingAccessPointImpl messagingAccessPoint = new MessagingAccessPointImpl(properties); - standaloneProducer = (StandaloneProducer) messagingAccessPoint.createProducer(properties); - } - - @Override - public void send(Message message, SendCallback sendCallback) throws Exception { - standaloneProducer.sendAsync(message, sendCallback); - } - - @Override - public void request(Message message, RRCallback rrCallback, long timeout) throws Exception { - throw new UnsupportedOperationException("not support request-reply mode when eventstore=standalone"); - } - - @Override - public boolean reply(Message message, SendCallback sendCallback) throws Exception { - throw new UnsupportedOperationException("not support request-reply mode when eventstore=standalone"); - } - - @Override - public void checkTopicExist(String topic) throws Exception { - boolean exist = standaloneProducer.checkTopicExist(topic); - if (!exist) { - throw new RuntimeException(String.format("topic:%s is not exist", topic)); - } - } - - @Override - public void setExtFields() { - - } - - @Override - public SendResult send(Message message) { - return standaloneProducer.send(message); - } - - @Override - public void sendOneway(Message message) { - standaloneProducer.sendOneway(message); - } - - @Override - public void sendAsync(Message message, SendCallback sendCallback) { - standaloneProducer.sendAsync(message, sendCallback); - } - - @Override - public void setCallbackExecutor(ExecutorService callbackExecutor) { - standaloneProducer.setCallbackExecutor(callbackExecutor); - } - - @Override - public void updateCredential(Properties credentialProperties) { - standaloneProducer.updateCredential(credentialProperties); - } - - @Override - public boolean isStarted() { - return standaloneProducer.isStarted(); - } - - @Override - public boolean isClosed() { - return standaloneProducer.isClosed(); - } - - @Override - public void start() { - standaloneProducer.start(); - } - - @Override - public void shutdown() { - standaloneProducer.shutdown(); - } - - @Override - public MessageBuilder messageBuilder() { - return null; - } -} diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/producer/StandaloneProducer.java b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/producer/StandaloneProducer.java index 1522f5124b..e6dce1a9bb 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/producer/StandaloneProducer.java +++ b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/producer/StandaloneProducer.java @@ -17,24 +17,25 @@ package org.apache.eventmesh.connector.standalone.producer; -import com.google.common.base.Preconditions; -import io.openmessaging.api.Message; -import io.openmessaging.api.MessageBuilder; -import io.openmessaging.api.OnExceptionContext; -import io.openmessaging.api.Producer; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; -import io.openmessaging.api.exception.OMSRuntimeException; +import org.apache.eventmesh.api.RequestReplyCallback; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.ConnectorRuntimeException; +import org.apache.eventmesh.api.exception.OnExceptionContext; import org.apache.eventmesh.connector.standalone.broker.StandaloneBroker; import org.apache.eventmesh.connector.standalone.broker.model.MessageEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Properties; -import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicBoolean; -public class StandaloneProducer implements Producer { +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Preconditions; + +import io.cloudevents.CloudEvent; + +public class StandaloneProducer { private Logger logger = LoggerFactory.getLogger(StandaloneProducer.class); @@ -47,81 +48,95 @@ public StandaloneProducer(Properties properties) { this.isStarted = new AtomicBoolean(false); } - @Override - public SendResult send(Message message) { - Preconditions.checkNotNull(message); + public boolean isStarted() { + return isStarted.get(); + } + + public boolean isClosed() { + return !isStarted.get(); + } + + public void start() { + isStarted.compareAndSet(false, true); + } + + public void shutdown() { + isStarted.compareAndSet(true, false); + } + + public StandaloneProducer init(Properties properties) throws Exception { + return new StandaloneProducer(properties); + } + + public SendResult publish(CloudEvent cloudEvent) { + Preconditions.checkNotNull(cloudEvent); try { - MessageEntity messageEntity = standaloneBroker.putMessage(message.getTopic(), message); + MessageEntity messageEntity = standaloneBroker.putMessage(cloudEvent.getSubject(), cloudEvent); SendResult sendResult = new SendResult(); - sendResult.setTopic(message.getTopic()); + sendResult.setTopic(cloudEvent.getSubject()); sendResult.setMessageId(String.valueOf(messageEntity.getOffset())); return sendResult; } catch (Exception e) { - logger.error("send message error, topic: {}", message.getTopic(), e); - throw new OMSRuntimeException(String.format("Send message error, topic: %s", message.getTopic())); + logger.error("send message error, topic: {}", cloudEvent.getSubject(), e); + throw new ConnectorRuntimeException( + String.format("Send message error, topic: %s", cloudEvent.getSubject())); } } - @Override - public void sendOneway(Message message) { - send(message); - } - - @Override - public void sendAsync(Message message, SendCallback sendCallback) { - Preconditions.checkNotNull(message); + public void publish(CloudEvent cloudEvent, SendCallback sendCallback) throws Exception { + Preconditions.checkNotNull(cloudEvent); Preconditions.checkNotNull(sendCallback); try { - SendResult sendResult = send(message); + SendResult sendResult = publish(cloudEvent); sendCallback.onSuccess(sendResult); } catch (Exception ex) { - OnExceptionContext exceptionContext = new OnExceptionContext(); - exceptionContext.setTopic(message.getTopic()); - exceptionContext.setException(new OMSRuntimeException(ex)); - exceptionContext.setMessageId(message.getMsgID()); - sendCallback.onException(exceptionContext); + OnExceptionContext onExceptionContext = OnExceptionContext.builder() + .messageId(cloudEvent.getId()) + .topic(cloudEvent.getSubject()) + .exception(new ConnectorRuntimeException(ex)) + .build(); + sendCallback.onException(onExceptionContext); } - - } - - @Override - public void setCallbackExecutor(ExecutorService callbackExecutor) { - } - @Override - public void updateCredential(Properties credentialProperties) { - + public void sendOneway(CloudEvent cloudEvent) { + publish(cloudEvent); } - @Override - public boolean isStarted() { - return isStarted.get(); + public void sendAsync(CloudEvent cloudEvent, SendCallback sendCallback) { + Preconditions.checkNotNull(cloudEvent, "CloudEvent cannot be null"); + Preconditions.checkNotNull(sendCallback, "Callback cannot be null"); + // todo: current is not async + try { + SendResult sendResult = publish(cloudEvent); + sendCallback.onSuccess(sendResult); + } catch (Exception ex) { + OnExceptionContext onExceptionContext = OnExceptionContext.builder() + .messageId(cloudEvent.getId()) + .topic(cloudEvent.getSubject()) + .exception(new ConnectorRuntimeException(ex)) + .build(); + sendCallback.onException(onExceptionContext); + } } - @Override - public boolean isClosed() { - return !isStarted.get(); + public void request(CloudEvent cloudEvent, RequestReplyCallback rrCallback, long timeout) throws Exception { + throw new ConnectorRuntimeException("Request is not supported"); } - @Override - public void start() { - isStarted.compareAndSet(false, true); + public boolean reply(CloudEvent cloudEvent, SendCallback sendCallback) throws Exception { + throw new ConnectorRuntimeException("Reply is not supported"); } - @Override - public void shutdown() { - isStarted.compareAndSet(true, false); - + public void checkTopicExist(String topic) throws Exception { + boolean exist = standaloneBroker.checkTopicExist(topic); + if (!exist) { + throw new ConnectorRuntimeException(String.format("topic:%s is not exist", topic)); + } } - @Override - public MessageBuilder messageBuilder() { - return null; - } + public void setExtFields() { - public boolean checkTopicExist(String topicName) { - return standaloneBroker.checkTopicExist(topicName); } } diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/producer/StandaloneProducerAdaptor.java b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/producer/StandaloneProducerAdaptor.java new file mode 100644 index 0000000000..8cff7e4f82 --- /dev/null +++ b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/java/org/apache/eventmesh/connector/standalone/producer/StandaloneProducerAdaptor.java @@ -0,0 +1,111 @@ +/* + * Licensed 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.eventmesh.connector.standalone.producer; + +import org.apache.eventmesh.api.RequestReplyCallback; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.producer.Producer; + +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.cloudevents.CloudEvent; + +public class StandaloneProducerAdaptor implements Producer { + + private final Logger logger = LoggerFactory.getLogger(StandaloneProducerAdaptor.class); + + private StandaloneProducer standaloneProducer; + + public StandaloneProducerAdaptor() { + } + + @Override + public boolean isStarted() { + return standaloneProducer.isStarted(); + } + + @Override + public boolean isClosed() { + return standaloneProducer.isClosed(); + } + + @Override + public void start() { + standaloneProducer.start(); + } + + @Override + public void shutdown() { + standaloneProducer.shutdown(); + } + + @Override + public void init(Properties properties) throws Exception { + standaloneProducer = new StandaloneProducer(properties); + } + + @Override + public SendResult publish(CloudEvent cloudEvent) { + return standaloneProducer.publish(cloudEvent); + } + + @Override + public void publish(CloudEvent cloudEvent, SendCallback sendCallback) throws Exception { + standaloneProducer.publish(cloudEvent, sendCallback); + } + + @Override + public void sendOneway(CloudEvent cloudEvent) { + standaloneProducer.sendOneway(cloudEvent); + } + + @Override + public void sendAsync(CloudEvent cloudEvent, SendCallback sendCallback) { + standaloneProducer.sendAsync(cloudEvent, sendCallback); + } + +// @Override +// public void request(CloudEvent cloudEvent, RRCallback rrCallback, long timeout) throws Exception { +// standaloneProducer.request(cloudEvent, rrCallback, timeout); +// } + + @Override + public void request(CloudEvent cloudEvent, RequestReplyCallback rrCallback, long timeout) throws Exception { + standaloneProducer.request(cloudEvent, rrCallback, timeout); + } + + @Override + public boolean reply(CloudEvent cloudEvent, SendCallback sendCallback) throws Exception { + return standaloneProducer.reply(cloudEvent, sendCallback); + } + + @Override + public void checkTopicExist(String topic) throws Exception { + standaloneProducer.checkTopicExist(topic); + } + + @Override + public void setExtFields() { + standaloneProducer.setExtFields(); + } + +} diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.consumer.MeshMQPushConsumer b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.consumer.Consumer similarity index 96% rename from eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.consumer.MeshMQPushConsumer rename to eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.consumer.Consumer index 190a92a303..5ceb0eda96 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.consumer.MeshMQPushConsumer +++ b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.consumer.Consumer @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -standalone=org.apache.eventmesh.connector.standalone.consumer.StandaloneMeshMQPushConsumerAdaptor \ No newline at end of file +standalone=org.apache.eventmesh.connector.standalone.consumer.StandaloneConsumerAdaptor \ No newline at end of file diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.producer.MeshMQProducer b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.producer.Producer similarity index 96% rename from eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.producer.MeshMQProducer rename to eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.producer.Producer index 4bbac31629..1b30d9837b 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.producer.MeshMQProducer +++ b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.producer.Producer @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -standalone=org.apache.eventmesh.connector.standalone.producer.StandaloneMeshMQProducerAdaptor \ No newline at end of file +standalone=org.apache.eventmesh.connector.standalone.producer.StandaloneProducerAdaptor \ No newline at end of file diff --git a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/test/java/org/apache/eventmesh/connector/standalone/broker/StandaloneBrokerTest.java b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/test/java/org/apache/eventmesh/connector/standalone/broker/StandaloneBrokerTest.java index a63be75698..92e4eb7dc9 100644 --- a/eventmesh-connector-plugin/eventmesh-connector-standalone/src/test/java/org/apache/eventmesh/connector/standalone/broker/StandaloneBrokerTest.java +++ b/eventmesh-connector-plugin/eventmesh-connector-standalone/src/test/java/org/apache/eventmesh/connector/standalone/broker/StandaloneBrokerTest.java @@ -17,11 +17,14 @@ package org.apache.eventmesh.connector.standalone.broker; -import io.openmessaging.api.Message; import org.apache.eventmesh.connector.standalone.broker.model.MessageEntity; + import org.junit.Assert; import org.junit.Test; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; + public class StandaloneBrokerTest { @Test @@ -32,15 +35,15 @@ public void getInstance() { @Test public void putMessage() throws InterruptedException { StandaloneBroker instance = StandaloneBroker.getInstance(); - MessageEntity messageEntity = instance.putMessage("test-topic", new Message()); + MessageEntity messageEntity = instance.putMessage("test-topic", CloudEventBuilder.v1().build()); Assert.assertNotNull(messageEntity); } @Test public void takeMessage() throws InterruptedException { StandaloneBroker instance = StandaloneBroker.getInstance(); - instance.putMessage("test-topic", new Message()); - Message message = instance.takeMessage("test-topic"); + instance.putMessage("test-topic", CloudEventBuilder.v1().build()); + CloudEvent message = instance.takeMessage("test-topic"); Assert.assertNotNull(message); } diff --git a/eventmesh-examples/build.gradle b/eventmesh-examples/build.gradle index f62d019d36..b46eaa2df7 100644 --- a/eventmesh-examples/build.gradle +++ b/eventmesh-examples/build.gradle @@ -15,80 +15,30 @@ * limitations under the License. */ -//group 'org.apache.eventmesh' -//version '1.2.0-SNAPSHOT' +def grpcVersion = '1.15.0' + +configurations { + implementation.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' +} dependencies { -// compile log4j2, sl4j -// testCompile log4j2, sl4j implementation project(":eventmesh-sdk-java") implementation project(":eventmesh-common") implementation project(":eventmesh-connector-plugin:eventmesh-connector-api") implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'io.netty:netty-all' + implementation "io.cloudevents:cloudevents-core" + implementation "io.cloudevents:cloudevents-json-jackson" + implementation "io.openmessaging:openmessaging-api" - testImplementation project(":eventmesh-sdk-java") - testImplementation project(":eventmesh-common") - testImplementation project(":eventmesh-connector-plugin:eventmesh-connector-api") - testImplementation 'org.springframework.boot:spring-boot-starter-web' - testImplementation 'io.netty:netty-all' - -} - -configurations.all { - exclude group: "ch.qos.logback" - exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' -} - -task testdist(dependsOn: ['jar']) { - - doFirst { - BasicTest - new File(projectDir.getPath(), 'dist/bin').mkdirs() - new File(projectDir.getPath(), 'dist/apps').mkdirs() - new File(projectDir.getPath(), 'dist/conf').mkdirs() - new File(projectDir.getPath(), 'dist/lib').mkdirs() - } + implementation "io.grpc:grpc-protobuf:${grpcVersion}" + implementation "io.grpc:grpc-stub:${grpcVersion}" + implementation "io.grpc:grpc-netty:${grpcVersion}" + implementation "io.grpc:grpc-netty-shaded:${grpcVersion}" - doLast { - copy { - into('dist/apps/') - from project.jar.getArchivePath() - } - copy { - into 'dist/lib' - from project.configurations.runtime - } - - copy { - into 'dist/bin' - from '../eventmesh-test/bin' - } - - copy { - into 'dist/conf' - from 'conf' - } - } -} - -task testtar(type: Tar) { - extension = 'tar.gz' - compression = Compression.GZIP - archiveName = project.name + '_' + project.version + '.' + extension - destinationDir = new File(projectDir.getPath(), 'build') - into('/') { - from 'dist' - } -} - -task packageTestSources(type: Jar) { - from project.sourceSets.main.allSource - classifier = 'sources' // either here or in artifacts block -} + compileOnly 'org.projectlombok:lombok:1.18.22' + annotationProcessor 'org.projectlombok:lombok:1.18.22' -artifacts { - archives jar - archives packageJavadoc - archives packageSources + testCompileOnly 'org.projectlombok:lombok:1.18.22' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' } \ No newline at end of file diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java new file mode 100644 index 0000000000..d8de043604 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java @@ -0,0 +1,82 @@ +/* + * Licensed 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.eventmesh.grpc.pub; + +import lombok.extern.slf4j.Slf4j; +import org.apache.eventmesh.client.grpc.EventMeshGrpcProducer; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; +import org.apache.eventmesh.util.Utils; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +@Slf4j +public class AsyncPublishInstance { + + // This messageSize is also used in SubService.java (Subscriber) + public static int messageSize = 5; + + public static void main(String[] args) throws Exception { + + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); + + final String topic = "TEST-TOPIC-HTTP-ASYNC"; + + EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() + .serverAddr(eventMeshIp) + .serverPort(Integer.parseInt(eventMeshGrpcPort)) + .producerGroup("EventMeshTest-producerGroup") + .env("env") + .idc("idc") + .ip(IPUtils.getLocalAddress()) + .sys("1234") + .pid(String.valueOf(ThreadUtils.getPID())).build(); + + EventMeshGrpcProducer eventMeshGrpcProducer = new EventMeshGrpcProducer(eventMeshClientConfig); + + eventMeshGrpcProducer.init(); + + Map content = new HashMap<>(); + content.put("content", "testAsyncMessage"); + + for (int i = 0; i < messageSize; i++) { + EventMeshMessage message = EventMeshMessage.newBuilder() + .setContent(JsonUtils.serialize(content)) + .setTopic(topic) + .setUniqueId(RandomStringUtils.generateNum(30)) + .setSeqNum(RandomStringUtils.generateNum(30)) + .setTtl(String.valueOf(4 * 1000)) + .build(); + + eventMeshGrpcProducer.publish(message); + Thread.sleep(1000); + } + Thread.sleep(30000); + try (EventMeshGrpcProducer ignore = eventMeshGrpcProducer) { + // ignore + } + } +} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/OpenSchemaRegistryApplication.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SpringBootDemoApplication.java similarity index 76% rename from eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/OpenSchemaRegistryApplication.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SpringBootDemoApplication.java index e6f96e8589..cf8ffb14b0 100644 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/OpenSchemaRegistryApplication.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SpringBootDemoApplication.java @@ -14,16 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.eventmesh.schema.registry.server; + +package org.apache.eventmesh.grpc.sub; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -@SpringBootApplication -public class OpenSchemaRegistryApplication { +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +public class SpringBootDemoApplication { public static void main(String[] args) { - SpringApplication.run(OpenSchemaRegistryApplication.class, args); + SpringApplication.run(SpringBootDemoApplication.class, args); } - } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java new file mode 100644 index 0000000000..91ebec357d --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java @@ -0,0 +1,67 @@ +/* + * Licensed 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.eventmesh.grpc.sub.controller; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.provider.EventFormatProvider; +import io.cloudevents.jackson.JsonFormat; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.grpc.sub.service.SubService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + + +@Slf4j +@RestController +@RequestMapping("/sub") +public class SubController { + + @Autowired + private SubService subService; + + @RequestMapping(value = "/test", method = RequestMethod.POST) + public String subTest(HttpServletRequest request) { + String content = request.getParameter("content"); + log.info("=======receive message======= {}", content); + Map contentMap = JsonUtils.deserialize(content, HashMap.class); + if (StringUtils.equals(EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME, contentMap.get(ProtocolKey.PROTOCOL_TYPE))) { + CloudEvent event = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE) + .deserialize(content.getBytes(StandardCharsets.UTF_8)); + String data = new String(event.getData().toBytes(), StandardCharsets.UTF_8); + log.info("=======receive data======= {}", data); + } + + subService.consumeMessage(content); + + Map map = new HashMap<>(); + map.put("retCode", 1); + return JsonUtils.serialize(map); + } + +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/service/SubService.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/service/SubService.java new file mode 100644 index 0000000000..90ff0c7190 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/service/SubService.java @@ -0,0 +1,130 @@ +/* + * Licensed 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.eventmesh.grpc.sub.service; + +import org.apache.eventmesh.client.grpc.EventMeshGrpcConsumer; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionType; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; +import org.apache.eventmesh.grpc.pub.AsyncPublishInstance; +import org.apache.eventmesh.util.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.stereotype.Component; +import javax.annotation.PreDestroy; +import java.util.Properties; +import java.util.concurrent.CountDownLatch; + +@Component +public class SubService implements InitializingBean { + + public static Logger logger = LoggerFactory.getLogger(SubService.class); + + private EventMeshGrpcConsumer eventMeshGrpcConsumer; + + final Properties properties = Utils.readPropertiesFile("application.properties"); + + final SubscriptionItem subscriptionItem = SubscriptionItem.newBuilder() + .setTopic("TEST-TOPIC-HTTP-ASYNC") + .setMode(SubscriptionMode.CLUSTERING) + .setType(SubscriptionType.ASYNC) + .build(); + + final String localIp = IPUtils.getLocalAddress(); + final String localPort = properties.getProperty("server.port"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); + final String url = "http://" + localIp + ":" + localPort + "/sub/test"; + final String env = "P"; + final String idc = "FT"; + final String subsys = "1234"; + + final Subscription subscription = Subscription.newBuilder() + .setUrl(url) + .addSubscriptionItems(subscriptionItem) + .build(); + + // CountDownLatch size is the same as messageSize in AsyncPublishInstance.java (Publisher) + private CountDownLatch countDownLatch = new CountDownLatch(AsyncPublishInstance.messageSize); + + @Override + public void afterPropertiesSet() throws Exception { + + EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() + .serverAddr(eventMeshIp) + .serverPort(Integer.parseInt(eventMeshGrpcPort)) + .consumerGroup("EventMeshTest-consumerGroup") + .env(env) + .idc(idc) + .ip(IPUtils.getLocalAddress()) + .sys(subsys) + .pid(String.valueOf(ThreadUtils.getPID())).build(); + + eventMeshGrpcConsumer = new EventMeshGrpcConsumer(eventMeshClientConfig); + eventMeshGrpcConsumer.init(); + eventMeshGrpcConsumer.subscribe(subscription); + + // Wait for all messaged to be consumed + Thread stopThread = new Thread(() -> { + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + logger.info("stopThread start...."); + System.exit(0); + }); + stopThread.start(); + } + + @PreDestroy + public void cleanup() { + logger.info("start destory ...."); + try { + /* List unSubList = new ArrayList<>(); + for (SubscriptionItem item : topicList) { + unSubList.add(item.getTopic()); + }*/ + // eventMeshHttpConsumer.unsubscribe(unSubList, url); + } catch (Exception e) { + e.printStackTrace(); + } + try (final EventMeshGrpcConsumer ignore = eventMeshGrpcConsumer) { + // close consumer + } catch (Exception e) { + e.printStackTrace(); + } + logger.info("end destory."); + } + + /** + * Count the message already consumed + */ + public void consumeMessage(String msg) { + logger.info("consume message {}", msg); + countDownLatch.countDown(); + logger.info("remaining number of messages to be consumed {}", countDownLatch.getCount()); + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/AsyncPublishInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/AsyncPublishInstance.java deleted file mode 100644 index b867885ce6..0000000000 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/AsyncPublishInstance.java +++ /dev/null @@ -1,94 +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 org.apache.eventmesh.http.demo; - -import java.util.Properties; - -import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.client.http.conf.LiteClientConfig; -import org.apache.eventmesh.client.http.producer.LiteProducer; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.LiteMessage; -import org.apache.eventmesh.common.RandomStringUtil; -import org.apache.eventmesh.common.ThreadUtil; -import org.apache.eventmesh.util.Utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AsyncPublishInstance { - - public static Logger logger = LoggerFactory.getLogger(AsyncPublishInstance.class); - - // This messageSize is also used in SubService.java (Subscriber) - public static int messageSize = 5; - - public static void main(String[] args) throws Exception { - Properties properties = Utils.readPropertiesFile("application.properties"); - final String eventMeshIp = properties.getProperty("eventmesh.ip"); - final String eventMeshHttpPort = properties.getProperty("eventmesh.http.port"); - - LiteProducer liteProducer = null; - try { -// String eventMeshIPPort = args[0]; - String eventMeshIPPort = eventMeshIp + ":" + eventMeshHttpPort; -// final String topic = args[1]; - final String topic = "TEST-TOPIC-HTTP-ASYNC"; - if (StringUtils.isBlank(eventMeshIPPort)) { - // if has multi value, can config as: 127.0.0.1:10105;127.0.0.2:10105 - eventMeshIPPort = "127.0.0.1:10105"; - } - - LiteClientConfig eventMeshClientConfig = new LiteClientConfig(); - eventMeshClientConfig.setLiteEventMeshAddr(eventMeshIPPort) - .setProducerGroup("EventMeshTest-producerGroup") - .setEnv("env") - .setIdc("idc") - .setIp(IPUtil.getLocalAddress()) - .setSys("1234") - .setPid(String.valueOf(ThreadUtil.getPID())); - - liteProducer = new LiteProducer(eventMeshClientConfig); - liteProducer.start(); - for (int i = 0; i < messageSize; i++) { - LiteMessage liteMessage = new LiteMessage(); - liteMessage.setBizSeqNo(RandomStringUtil.generateNum(30)) -// .setContent("contentStr with special protocal") - .setContent("testPublishMessage") - .setTopic(topic) - .setUniqueId(RandomStringUtil.generateNum(30)) - .addProp(Constants.EVENTMESH_MESSAGE_CONST_TTL, String.valueOf(4 * 1000)); - - boolean flag = liteProducer.publish(liteMessage); - Thread.sleep(1000); - logger.info("publish result , {}", flag); - } - } catch (Exception e) { - logger.warn("publish msg failed", e); - } - - try { - Thread.sleep(30000); - if (liteProducer != null) { - liteProducer.shutdown(); - } - } catch (Exception e1) { - logger.warn("producer shutdown exception", e1); - } - } -} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/AsyncSyncRequestInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/AsyncSyncRequestInstance.java deleted file mode 100644 index ba2d99ccd2..0000000000 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/AsyncSyncRequestInstance.java +++ /dev/null @@ -1,99 +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 org.apache.eventmesh.http.demo; - -import java.util.Properties; - -import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.client.http.conf.LiteClientConfig; -import org.apache.eventmesh.client.http.producer.LiteProducer; -import org.apache.eventmesh.client.http.producer.RRCallback; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.LiteMessage; -import org.apache.eventmesh.common.RandomStringUtil; -import org.apache.eventmesh.common.ThreadUtil; -import org.apache.eventmesh.util.Utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AsyncSyncRequestInstance { - - public static Logger logger = LoggerFactory.getLogger(AsyncSyncRequestInstance.class); - - public static void main(String[] args) throws Exception { - - Properties properties = Utils.readPropertiesFile("application.properties"); - final String eventMeshIp = properties.getProperty("eventmesh.ip"); - final String eventMeshHttpPort = properties.getProperty("eventmesh.http.port"); - - LiteProducer liteProducer = null; - try { -// String eventMeshIPPort = args[0]; - String eventMeshIPPort = eventMeshIp + ":" + eventMeshHttpPort; -// final String topic = args[1]; - final String topic = "TEST-TOPIC-TCP-ASYNC"; - if (StringUtils.isBlank(eventMeshIPPort)) { - // if has multi value, can config as: 127.0.0.1:10105;127.0.0.2:10105 - eventMeshIPPort = "127.0.0.1:10105"; - } - - LiteClientConfig eventMeshClientConfig = new LiteClientConfig(); - eventMeshClientConfig.setLiteEventMeshAddr(eventMeshIPPort) - .setProducerGroup("EventMeshTest-producerGroup") - .setEnv("env") - .setIdc("idc") - .setIp(IPUtil.getLocalAddress()) - .setSys("1234") - .setPid(String.valueOf(ThreadUtil.getPID())); - - liteProducer = new LiteProducer(eventMeshClientConfig); - - final long startTime = System.currentTimeMillis(); - final LiteMessage liteMessage = new LiteMessage(); - liteMessage.setBizSeqNo(RandomStringUtil.generateNum(30)) - .setContent("testAsyncMessage") - .setTopic(topic) - .setUniqueId(RandomStringUtil.generateNum(30)); - - liteProducer.request(liteMessage, new RRCallback() { - @Override - public void onSuccess(LiteMessage o) { - logger.debug("sendmsg : {}, return : {}, cost:{}ms", liteMessage.getContent(), o.getContent(), System.currentTimeMillis() - startTime); - } - - @Override - public void onException(Throwable e) { - logger.debug("sendmsg failed", e); - } - }, 3000); - - Thread.sleep(2000); - } catch (Exception e) { - logger.warn("async send msg failed", e); - } - - try { - Thread.sleep(30000); - if (liteProducer != null) { - liteProducer.shutdown(); - } - } catch (Exception e1) { - logger.warn("producer shutdown exception", e1); - } - } -} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/pub/cloudevents/AsyncPublishInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/pub/cloudevents/AsyncPublishInstance.java new file mode 100644 index 0000000000..0f98ac2fa3 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/pub/cloudevents/AsyncPublishInstance.java @@ -0,0 +1,97 @@ +/* + * Licensed 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.eventmesh.http.demo.pub.cloudevents; + +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.producer.EventMeshHttpProducer; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.EventMeshMessage; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; +import org.apache.eventmesh.util.Utils; + +import org.apache.commons.lang3.StringUtils; + +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import lombok.extern.slf4j.Slf4j; +import static org.apache.eventmesh.tcp.common.EventMeshTestCaseTopicSet.TOPIC_PRX_WQ2ClientUniCast; + +@Slf4j +public class AsyncPublishInstance { + + // This messageSize is also used in SubService.java (Subscriber) + public static int messageSize = 5; + + public static void main(String[] args) throws Exception { + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshHttpPort = properties.getProperty("eventmesh.http.port"); + + final String eventMeshIPPort; + if (StringUtils.isBlank(eventMeshIp) || StringUtils.isBlank(eventMeshHttpPort)) { + // if has multi value, can config as: 127.0.0.1:10105;127.0.0.2:10105 + eventMeshIPPort = "127.0.0.1:10105"; + } else { + eventMeshIPPort = eventMeshIp + ":" + eventMeshHttpPort; + } + + final String topic = "TEST-TOPIC-HTTP-ASYNC"; + + EventMeshHttpClientConfig eventMeshClientConfig = EventMeshHttpClientConfig.builder() + .liteEventMeshAddr(eventMeshIPPort) + .producerGroup("EventMeshTest-producerGroup") + .env("env") + .idc("idc") + .ip(IPUtils.getLocalAddress()) + .sys("1234") + .pid(String.valueOf(ThreadUtils.getPID())) + .userName("eventmesh") + .password("pass") + .build(); + + try (EventMeshHttpProducer eventMeshHttpProducer = new EventMeshHttpProducer(eventMeshClientConfig)) { + for (int i = 0; i < messageSize; i++) { + Map content = new HashMap<>(); + content.put("content", "testAsyncMessage"); + + CloudEvent event = CloudEventBuilder.v1() + .withId(UUID.randomUUID().toString()) + .withSubject(topic) + .withSource(URI.create("/")) + .withDataContentType("application/cloudevents+json") + .withType(EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME) + .withData(JsonUtils.serialize(content).getBytes(StandardCharsets.UTF_8)) + .withExtension(Constants.EVENTMESH_MESSAGE_CONST_TTL, String.valueOf(4 * 1000)) + .build(); + eventMeshHttpProducer.publish(event); + } + Thread.sleep(30000); + } + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/pub/eventmeshmessage/AsyncPublishInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/pub/eventmeshmessage/AsyncPublishInstance.java new file mode 100644 index 0000000000..751cb2cf97 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/pub/eventmeshmessage/AsyncPublishInstance.java @@ -0,0 +1,88 @@ +/* + * Licensed 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.eventmesh.http.demo.pub.eventmeshmessage; + +import lombok.extern.slf4j.Slf4j; + +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.producer.EventMeshHttpProducer; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.EventMeshMessage; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; +import org.apache.eventmesh.util.Utils; + +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +@Slf4j +public class AsyncPublishInstance { + + // This messageSize is also used in SubService.java (Subscriber) + public static int messageSize = 5; + + public static void main(String[] args) throws Exception { + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshHttpPort = properties.getProperty("eventmesh.http.port"); + + final String eventMeshIPPort; + if (StringUtils.isBlank(eventMeshIp) || StringUtils.isBlank(eventMeshHttpPort)) { + // if has multi value, can config as: 127.0.0.1:10105;127.0.0.2:10105 + eventMeshIPPort = "127.0.0.1:10105"; + } else { + eventMeshIPPort = eventMeshIp + ":" + eventMeshHttpPort; + } + + final String topic = "TEST-TOPIC-HTTP-ASYNC"; + + EventMeshHttpClientConfig eventMeshClientConfig = EventMeshHttpClientConfig.builder() + .liteEventMeshAddr(eventMeshIPPort) + .producerGroup("EventMeshTest-producerGroup") + .env("env") + .idc("idc") + .ip(IPUtils.getLocalAddress()) + .sys("1234") + .pid(String.valueOf(ThreadUtils.getPID())) + .userName("eventmesh") + .password("pass") + .build(); + + try (EventMeshHttpProducer eventMeshHttpProducer = new EventMeshHttpProducer(eventMeshClientConfig);) { + for (int i = 0; i < messageSize; i++) { + Map content = new HashMap<>(); + content.put("content", "testPublishMessage"); + + EventMeshMessage eventMeshMessage = EventMeshMessage.builder() + .bizSeqNo(RandomStringUtils.generateNum(30)) + .content(JsonUtils.serialize(content)) + .topic(topic) + .uniqueId(RandomStringUtils.generateNum(30)) + .build() + .addProp(Constants.EVENTMESH_MESSAGE_CONST_TTL, String.valueOf(4 * 1000)); + eventMeshHttpProducer.publish(eventMeshMessage); + } + Thread.sleep(30000); + } + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/pub/eventmeshmessage/AsyncSyncRequestInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/pub/eventmeshmessage/AsyncSyncRequestInstance.java new file mode 100644 index 0000000000..428472634a --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/pub/eventmeshmessage/AsyncSyncRequestInstance.java @@ -0,0 +1,99 @@ +/* + * Licensed 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.eventmesh.http.demo.pub.eventmeshmessage; + +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.producer.EventMeshHttpProducer; +import org.apache.eventmesh.client.http.producer.RRCallback; +import org.apache.eventmesh.common.EventMeshMessage; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; +import org.apache.eventmesh.util.Utils; + +import org.apache.commons.lang3.StringUtils; + +import java.util.Properties; + +import com.google.common.base.Preconditions; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class AsyncSyncRequestInstance { + + public static void main(String[] args) throws Exception { + + Properties properties = Utils.readPropertiesFile("application.properties"); + Preconditions.checkNotNull(properties, "application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshHttpPort = properties.getProperty("eventmesh.http.port"); + + EventMeshHttpProducer eventMeshHttpProducer = null; + try { + String eventMeshIPPort = eventMeshIp + ":" + eventMeshHttpPort; + final String topic = "TEST-TOPIC-TCP-ASYNC"; + if (StringUtils.isBlank(eventMeshIPPort)) { + // if has multi value, can config as: 127.0.0.1:10105;127.0.0.2:10105 + eventMeshIPPort = "127.0.0.1:10105"; + } + + EventMeshHttpClientConfig eventMeshClientConfig = EventMeshHttpClientConfig.builder() + .liteEventMeshAddr(eventMeshIPPort) + .producerGroup("EventMeshTest-producerGroup") + .env("env") + .idc("idc") + .ip(IPUtils.getLocalAddress()) + .sys("1234") + .pid(String.valueOf(ThreadUtils.getPID())).build(); + + eventMeshHttpProducer = new EventMeshHttpProducer(eventMeshClientConfig); + + final long startTime = System.currentTimeMillis(); + final EventMeshMessage eventMeshMessage = EventMeshMessage.builder() + .bizSeqNo(RandomStringUtils.generateNum(30)) + .content("testAsyncMessage") + .topic(topic) + .uniqueId(RandomStringUtils.generateNum(30)).build(); + + eventMeshHttpProducer.request(eventMeshMessage, new RRCallback() { + @Override + public void onSuccess(EventMeshMessage o) { + log.debug("sendmsg : {}, return : {}, cost:{}ms", eventMeshMessage.getContent(), o.getContent(), + System.currentTimeMillis() - startTime); + } + + @Override + public void onException(Throwable e) { + log.debug("send msg failed", e); + } + }, 3000); + + Thread.sleep(2000); + } catch (Exception e) { + log.warn("async send msg failed", e); + } + + Thread.sleep(30000); + try (final EventMeshHttpProducer ignore = eventMeshHttpProducer) { + // close producer + } catch (Exception e1) { + log.warn("producer shutdown exception", e1); + } + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/SyncRequestInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/pub/eventmeshmessage/SyncRequestInstance.java similarity index 55% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/SyncRequestInstance.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/pub/eventmeshmessage/SyncRequestInstance.java index a88396bedf..4d7e1d2642 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/SyncRequestInstance.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/pub/eventmeshmessage/SyncRequestInstance.java @@ -15,15 +15,17 @@ * limitations under the License. */ -package org.apache.eventmesh.http.demo; +package org.apache.eventmesh.http.demo.pub.eventmeshmessage; + +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.producer.EventMeshHttpProducer; +import org.apache.eventmesh.common.EventMeshMessage; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.client.http.conf.LiteClientConfig; -import org.apache.eventmesh.client.http.producer.LiteProducer; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.LiteMessage; -import org.apache.eventmesh.common.RandomStringUtil; -import org.apache.eventmesh.common.ThreadUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +35,7 @@ public class SyncRequestInstance { public static void main(String[] args) throws Exception { - LiteProducer liteProducer = null; + EventMeshHttpProducer eventMeshHttpProducer = null; String eventMeshIPPort = "127.0.0.1:10105"; String topic = "EventMesh.SyncRequestInstance"; try { @@ -49,38 +51,36 @@ public static void main(String[] args) throws Exception { eventMeshIPPort = "127.0.0.1:10105"; } - LiteClientConfig eventMeshClientConfig = new LiteClientConfig(); - eventMeshClientConfig.setLiteEventMeshAddr(eventMeshIPPort) - .setProducerGroup("EventMeshTest-producerGroup") - .setEnv("env") - .setIdc("idc") - .setIp(IPUtil.getLocalAddress()) - .setSys("1234") - .setPid(String.valueOf(ThreadUtil.getPID())); + EventMeshHttpClientConfig eventMeshClientConfig = EventMeshHttpClientConfig.builder() + .liteEventMeshAddr(eventMeshIPPort) + .producerGroup("EventMeshTest-producerGroup") + .env("env") + .idc("idc") + .ip(IPUtils.getLocalAddress()) + .sys("1234") + .pid(String.valueOf(ThreadUtils.getPID())).build(); - liteProducer = new LiteProducer(eventMeshClientConfig); - liteProducer.start(); + eventMeshHttpProducer = new EventMeshHttpProducer(eventMeshClientConfig); long startTime = System.currentTimeMillis(); - LiteMessage liteMessage = new LiteMessage(); - liteMessage.setBizSeqNo(RandomStringUtil.generateNum(30)) - .setContent("contentStr with special protocal") - .setTopic(topic) - .setUniqueId(RandomStringUtil.generateNum(30)); + EventMeshMessage eventMeshMessage = EventMeshMessage.builder() + .bizSeqNo(RandomStringUtils.generateNum(30)) + .content("contentStr with special protocal") + .topic(topic) + .uniqueId(RandomStringUtils.generateNum(30)).build(); - LiteMessage rsp = liteProducer.request(liteMessage, 10000); + EventMeshMessage rsp = eventMeshHttpProducer.request(eventMeshMessage, 10000); if (logger.isDebugEnabled()) { - logger.debug("sendmsg : {}, return : {}, cost:{}ms", liteMessage.getContent(), rsp.getContent(), System.currentTimeMillis() - startTime); + logger.debug("sendmsg : {}, return : {}, cost:{}ms", eventMeshMessage.getContent(), rsp.getContent(), + System.currentTimeMillis() - startTime); } } catch (Exception e) { logger.warn("send msg failed", e); } - try { - Thread.sleep(30000); - if (liteProducer != null) { - liteProducer.shutdown(); - } + Thread.sleep(30000); + try (final EventMeshHttpProducer close = eventMeshHttpProducer) { + // close producer } catch (Exception e1) { logger.warn("producer shutdown exception", e1); } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/sub/controller/SubController.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/sub/controller/SubController.java index aa400ceb63..c82864b4be 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/sub/controller/SubController.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/sub/controller/SubController.java @@ -17,33 +17,51 @@ package org.apache.eventmesh.http.demo.sub.controller; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.provider.EventFormatProvider; +import io.cloudevents.jackson.JsonFormat; +import lombok.extern.slf4j.Slf4j; + +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.http.demo.sub.service.SubService; +import org.apache.commons.lang3.StringUtils; + +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import javax.servlet.http.HttpServletRequest; + import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; + +@Slf4j @RestController @RequestMapping("/sub") public class SubController { - public static Logger logger = LoggerFactory.getLogger(SubController.class); - @Autowired private SubService subService; @RequestMapping(value = "/test", method = RequestMethod.POST) - public String subTest(@RequestBody String message) { - logger.info("=======receive message======= {}", JsonUtils.serialize(message)); - subService.consumeMessage(message); + public String subTest(HttpServletRequest request) { + String content = request.getParameter("content"); + log.info("=======receive message======= {}", content); + Map contentMap = JsonUtils.deserialize(content, HashMap.class); + if (StringUtils.equals(EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME, contentMap.get(ProtocolKey.PROTOCOL_TYPE))) { + CloudEvent event = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE) + .deserialize(content.getBytes(StandardCharsets.UTF_8)); + String data = new String(event.getData().toBytes(), StandardCharsets.UTF_8); + log.info("=======receive data======= {}", data); + } + + subService.consumeMessage(content); Map map = new HashMap<>(); map.put("retCode", 1); diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/sub/service/SubService.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/sub/service/SubService.java index 0772fca952..0c0f2c1928 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/sub/service/SubService.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/http/demo/sub/service/SubService.java @@ -19,48 +19,50 @@ package org.apache.eventmesh.http.demo.sub.service; +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.consumer.EventMeshHttpConsumer; +import org.apache.eventmesh.common.protocol.SubscriptionItem; +import org.apache.eventmesh.common.protocol.SubscriptionMode; +import org.apache.eventmesh.common.protocol.SubscriptionType; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; +import org.apache.eventmesh.http.demo.pub.eventmeshmessage.AsyncPublishInstance; +import org.apache.eventmesh.util.Utils; + import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Properties; import java.util.concurrent.CountDownLatch; -import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.client.http.conf.LiteClientConfig; -import org.apache.eventmesh.client.http.consumer.LiteConsumer; -import org.apache.eventmesh.common.EventMeshException; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.ThreadUtil; -import org.apache.eventmesh.common.protocol.SubscriptionType; -import org.apache.eventmesh.common.protocol.SubscriptionItem; -import org.apache.eventmesh.common.protocol.SubscriptionMode; -import org.apache.eventmesh.http.demo.AsyncPublishInstance; -import org.apache.eventmesh.util.Utils; + +import javax.annotation.PreDestroy; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.stereotype.Component; -import javax.annotation.PreDestroy; + +import com.google.common.collect.Lists; @Component public class SubService implements InitializingBean { public static Logger logger = LoggerFactory.getLogger(SubService.class); - private LiteConsumer liteConsumer; - - private String eventMeshIPPort = ""; + private EventMeshHttpConsumer eventMeshHttpConsumer; final Properties properties = Utils.readPropertiesFile("application.properties"); - final List topicList = Arrays.asList(new SubscriptionItem("TEST-TOPIC-HTTP-ASYNC", SubscriptionMode.CLUSTERING, SubscriptionType.ASYNC)); - final String localIp = IPUtil.getLocalAddress(); - final String localPort = properties.getProperty("server.port"); - final String eventMeshIp = properties.getProperty("eventmesh.ip"); - final String eventMeshHttpPort = properties.getProperty("eventmesh.http.port"); - final String url = "http://" + localIp + ":" + localPort + "/sub/test"; - final String env = "P"; - final String idc = "FT"; - final String subsys = "1234"; + final List topicList = Lists.newArrayList( + new SubscriptionItem("TEST-TOPIC-HTTP-ASYNC", SubscriptionMode.CLUSTERING, SubscriptionType.ASYNC) + ); + final String localIp = IPUtils.getLocalAddress(); + final String localPort = properties.getProperty("server.port"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshHttpPort = properties.getProperty("eventmesh.http.port"); + final String url = "http://" + localIp + ":" + localPort + "/sub/test"; + final String env = "P"; + final String idc = "FT"; + final String subsys = "1234"; // CountDownLatch size is the same as messageSize in AsyncPublishInstance.java (Publisher) private CountDownLatch countDownLatch = new CountDownLatch(AsyncPublishInstance.messageSize); @@ -68,23 +70,19 @@ public class SubService implements InitializingBean { @Override public void afterPropertiesSet() throws Exception { - if (StringUtils.isBlank(eventMeshIPPort)) { - // if has multi value, can config as: 127.0.0.1:10105;127.0.0.2:10105 - eventMeshIPPort = eventMeshIp + ":" + eventMeshHttpPort; - } - LiteClientConfig eventMeshClientConfig = new LiteClientConfig(); - eventMeshClientConfig.setLiteEventMeshAddr(eventMeshIPPort) - .setConsumerGroup("EventMeshTest-consumerGroup") - .setEnv(env) - .setIdc(idc) - .setIp(IPUtil.getLocalAddress()) - .setSys(subsys) - .setPid(String.valueOf(ThreadUtil.getPID())); - - liteConsumer = new LiteConsumer(eventMeshClientConfig); - liteConsumer.start(); - liteConsumer.heartBeat(topicList, url); - liteConsumer.subscribe(topicList, url); + final String eventMeshIPPort = eventMeshIp + ":" + eventMeshHttpPort; + EventMeshHttpClientConfig eventMeshClientConfig = EventMeshHttpClientConfig.builder() + .liteEventMeshAddr(eventMeshIPPort) + .consumerGroup("EventMeshTest-consumerGroup") + .env(env) + .idc(idc) + .ip(IPUtils.getLocalAddress()) + .sys(subsys) + .pid(String.valueOf(ThreadUtils.getPID())).build(); + + eventMeshHttpConsumer = new EventMeshHttpConsumer(eventMeshClientConfig); + eventMeshHttpConsumer.heartBeat(topicList, url); + eventMeshHttpConsumer.subscribe(topicList, url); // Wait for all messaged to be consumed Thread stopThread = new Thread(() -> { @@ -104,15 +102,15 @@ public void cleanup() { logger.info("start destory ...."); try { List unSubList = new ArrayList<>(); - for (SubscriptionItem item:topicList) { + for (SubscriptionItem item : topicList) { unSubList.add(item.getTopic()); } - liteConsumer.unsubscribe(unSubList, url); + eventMeshHttpConsumer.unsubscribe(unSubList, url); } catch (Exception e) { e.printStackTrace(); } - try { - liteConsumer.shutdown(); + try (final EventMeshHttpConsumer ignore = eventMeshHttpConsumer) { + // close consumer } catch (Exception e) { e.printStackTrace(); } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/common/EventMeshTestUtils.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/common/EventMeshTestUtils.java index 88f5016e9d..dad5e65d24 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/common/EventMeshTestUtils.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/common/EventMeshTestUtils.java @@ -17,55 +17,69 @@ package org.apache.eventmesh.tcp.common; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import io.cloudevents.core.v1.CloudEventV1; import static org.apache.eventmesh.common.protocol.tcp.Command.RESPONSE_TO_SERVER; import static org.apache.eventmesh.tcp.common.EventMeshTestCaseTopicSet.TOPIC_PRX_SyncSubscribeTest; import static org.apache.eventmesh.tcp.common.EventMeshTestCaseTopicSet.TOPIC_PRX_WQ2ClientBroadCast; import static org.apache.eventmesh.tcp.common.EventMeshTestCaseTopicSet.TOPIC_PRX_WQ2ClientUniCast; -import java.util.concurrent.ThreadLocalRandom; - import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.client.tcp.common.MessageUtils; import org.apache.eventmesh.common.protocol.tcp.Command; import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; import org.apache.eventmesh.common.protocol.tcp.Header; import org.apache.eventmesh.common.protocol.tcp.Package; import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.common.utils.JsonUtils; + +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; public class EventMeshTestUtils { private static final int seqLength = 10; + // generate pub-client public static UserAgent generateClient1() { - UserAgent user = new UserAgent(); - user.setEnv("test"); - user.setHost("127.0.0.1"); - user.setPassword(generateRandomString(8)); - user.setUsername("PU4283"); - user.setProducerGroup("EventmeshTest-ProducerGroup"); - user.setConsumerGroup("EventmeshTest-ConsumerGroup"); - user.setPath("/data/app/umg_proxy"); - user.setPort(8362); - user.setSubsystem("5023"); - user.setPid(32893); - user.setVersion("2.0.11"); - user.setIdc("FT"); - return user; + UserAgent agent = UserAgent.builder() + .env("test") + .host("127.0.0.1") + .password(generateRandomString(8)) + .username("PU4283") + .producerGroup("EventmeshTest-ProducerGroup") + .consumerGroup("EventmeshTest-ConsumerGroup") + .path("/data/app/umg_proxy") + .port(8362) + .subsystem("5023") + .pid(32893) + .version("2.0.11") + .idc("FT") + .build(); + return MessageUtils.generatePubClient(agent); } + // generate sub-client public static UserAgent generateClient2() { - UserAgent user = new UserAgent(); - user.setEnv("test"); - user.setHost("127.0.0.1"); - user.setPassword(generateRandomString(8)); - user.setUsername("PU4283"); - user.setConsumerGroup("EventmeshTest-ConsumerGroup"); - user.setProducerGroup("EventmeshTest-ProducerGroup"); - user.setPath("/data/app/umg_proxy"); - user.setPort(9362); - user.setSubsystem("5017"); - user.setPid(42893); - user.setVersion("2.0.11"); - user.setIdc("FT"); - return user; + UserAgent agent = UserAgent.builder() + .env("test") + .host("127.0.0.1") + .password(generateRandomString(8)) + .username("PU4283") + .producerGroup("EventmeshTest-ProducerGroup") + .consumerGroup("EventmeshTest-ConsumerGroup") + .path("/data/app/umg_proxy") + .port(9362) + .subsystem("5017") + .pid(42893) + .version("2.0.11") + .idc("FT") + .build(); + return MessageUtils.generateSubClient(agent); } public static Package syncRR() { @@ -96,19 +110,19 @@ public static Package broadcastMessage() { return msg; } - public static Package rrResponse(Package request) { + public static Package rrResponse(EventMeshMessage request) { Package msg = new Package(); msg.setHeader(new Header(RESPONSE_TO_SERVER, 0, null, generateRandomString(seqLength))); - msg.setBody(request.getBody()); + msg.setBody(request); return msg; } - private static EventMeshMessage generateSyncRRMqMsg() { + public static EventMeshMessage generateSyncRRMqMsg() { EventMeshMessage mqMsg = new EventMeshMessage(); mqMsg.setTopic(TOPIC_PRX_SyncSubscribeTest); - mqMsg.getProperties().put("msgType", "persistent"); - mqMsg.getProperties().put("TTL", "300000"); - mqMsg.getProperties().put("KEYS", generateRandomString(16)); + mqMsg.getProperties().put("msgtype", "persistent"); + mqMsg.getProperties().put("ttl", "300000"); + mqMsg.getProperties().put("keys", generateRandomString(16)); mqMsg.setBody("testSyncRR"); return mqMsg; } @@ -117,29 +131,29 @@ private static EventMeshMessage generateSyncRRMqMsg() { private static EventMeshMessage generateAsyncRRMqMsg() { EventMeshMessage mqMsg = new EventMeshMessage(); mqMsg.setTopic(TOPIC_PRX_SyncSubscribeTest); - mqMsg.getProperties().put("REPLY_TO", "10.36.0.109@ProducerGroup-producerPool-9-access#V1_4_0#CI"); - mqMsg.getProperties().put("TTL", "300000"); - mqMsg.getProperties().put("PROPERTY_MESSAGE_REPLY_TO", "notnull"); + mqMsg.getProperties().put("replyto", "10.36.0.109@ProducerGroup-producerPool-9-access#V1_4_0#CI"); + mqMsg.getProperties().put("ttl", "300000"); + mqMsg.getProperties().put("propertymessagereplyto", "notnull"); mqMsg.setBody("testAsyncRR"); return mqMsg; } - private static EventMeshMessage generateAsyncEventMqMsg() { + public static EventMeshMessage generateAsyncEventMqMsg() { EventMeshMessage mqMsg = new EventMeshMessage(); mqMsg.setTopic(TOPIC_PRX_WQ2ClientUniCast); - mqMsg.getProperties().put("REPLY_TO", "10.36.0.109@ProducerGroup-producerPool-9-access#V1_4_0#CI"); - mqMsg.getProperties().put("TTL", "30000"); - mqMsg.getProperties().put("PROPERTY_MESSAGE_REPLY_TO", "notnull"); + mqMsg.getProperties().put("replyto", "10.36.0.109@ProducerGroup-producerPool-9-access#V1_4_0#CI"); + mqMsg.getProperties().put("ttl", "30000"); + mqMsg.getProperties().put("propertymessagereplyto", "notnull"); mqMsg.setBody("testAsyncMessage"); return mqMsg; } - private static EventMeshMessage generateBroadcastMqMsg() { + public static EventMeshMessage generateBroadcastMqMsg() { EventMeshMessage mqMsg = new EventMeshMessage(); mqMsg.setTopic(TOPIC_PRX_WQ2ClientBroadCast); - mqMsg.getProperties().put("REPLY_TO", "10.36.0.109@ProducerGroup-producerPool-9-access#V1_4_0#CI"); - mqMsg.getProperties().put("TTL", "30000"); - mqMsg.getProperties().put("PROPERTY_MESSAGE_REPLY_TO", "notnull"); + mqMsg.getProperties().put("replyto", "10.36.0.109@ProducerGroup-producerPool-9-access#V1_4_0#CI"); + mqMsg.getProperties().put("ttl", "30000"); + mqMsg.getProperties().put("propertymessagereplyto", "notnull"); mqMsg.setBody("testAsyncMessage"); return mqMsg; } @@ -151,4 +165,38 @@ private static String generateRandomString(int length) { } return builder.toString(); } + + public static CloudEvent generateCloudEventV1Async() { + Map content = new HashMap<>(); + content.put("content", "testAsyncMessage"); + + CloudEvent event = CloudEventBuilder.v1() + .withId(UUID.randomUUID().toString()) + .withSubject(TOPIC_PRX_WQ2ClientUniCast) + .withSource(URI.create("/")) + .withDataContentType("application/cloudevents+json") + .withType(EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME) + .withData(JsonUtils.serialize(content).getBytes(StandardCharsets.UTF_8)) + .withExtension("ttl", "30000") + .build(); + return event; + } + + public static CloudEvent generateCloudEventV1SyncRR() { + Map content = new HashMap<>(); + content.put("content", "testSyncRR"); + + CloudEvent event = CloudEventBuilder.v1() + .withId(UUID.randomUUID().toString()) + .withSubject(TOPIC_PRX_SyncSubscribeTest) + .withSource(URI.create("/")) + .withDataContentType("application/cloudevents+json") + .withType(EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME) + .withData(JsonUtils.serialize(content).getBytes(StandardCharsets.UTF_8)) + .withExtension("ttl", "30000") + .withExtension("msgtype", "persistent") + .withExtension("keys", generateRandomString(16)) + .build(); + return event; + } } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/SyncRequest.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/SyncRequest.java deleted file mode 100644 index 15f01e155e..0000000000 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/SyncRequest.java +++ /dev/null @@ -1,55 +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 org.apache.eventmesh.tcp.demo; - -import org.apache.eventmesh.client.tcp.EventMeshClient; -import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; -import org.apache.eventmesh.tcp.common.EventMeshTestUtils; -import org.apache.eventmesh.common.protocol.tcp.Package; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SyncRequest { - - public static Logger logger = LoggerFactory.getLogger(SyncRequest.class); - - private static EventMeshClient client; - - public static void main(String[] agrs) throws Exception { - try { - UserAgent userAgent = EventMeshTestUtils.generateClient1(); - client = new DefaultEventMeshClient("127.0.0.1", 10000, userAgent); - client.init(); - client.heartbeat(); - - Package rrMsg = EventMeshTestUtils.syncRR(); - logger.info("begin send rr msg=================={}", rrMsg); - Package response = client.rr(rrMsg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - logger.info("receive rr reply==================={}", response); - - // release resource and close client - // client.close(); - } catch (Exception e) { - logger.warn("SyncRequest failed", e); - } - } -} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/AsyncPublish.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/cloudevents/AsyncPublish.java similarity index 69% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/AsyncPublish.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/cloudevents/AsyncPublish.java index 4cbac1923a..f7321d4b76 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/AsyncPublish.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/cloudevents/AsyncPublish.java @@ -15,17 +15,20 @@ * limitations under the License. */ -package org.apache.eventmesh.tcp.demo; +package org.apache.eventmesh.tcp.demo.pub.cloudevents; -import java.util.Properties; +import io.cloudevents.CloudEvent; -import org.apache.eventmesh.client.tcp.EventMeshClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.EventMeshTCPClientFactory; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.tcp.common.EventMeshTestUtils; import org.apache.eventmesh.util.Utils; + +import java.util.Properties; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +36,7 @@ public class AsyncPublish { public static Logger logger = LoggerFactory.getLogger(AsyncPublish.class); - private static EventMeshClient client; + private static EventMeshTCPClient client; public static AsyncPublish handler = new AsyncPublish(); @@ -43,21 +46,23 @@ public static void main(String[] agrs) throws Exception { final int eventMeshTcpPort = Integer.parseInt(properties.getProperty("eventmesh.tcp.port")); try { UserAgent userAgent = EventMeshTestUtils.generateClient1(); - client = new DefaultEventMeshClient(eventMeshIp, eventMeshTcpPort, userAgent); + EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder() + .host(eventMeshIp) + .port(eventMeshTcpPort) + .userAgent(userAgent) + .build(); + client = + EventMeshTCPClientFactory.createEventMeshTCPClient(eventMeshTcpClientConfig, CloudEvent.class); client.init(); - client.heartbeat(); for (int i = 0; i < 5; i++) { - Package asyncMsg = EventMeshTestUtils.asyncMessage(); - logger.info("begin send async msg[{}]==================={}", i, asyncMsg); - client.publish(asyncMsg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + CloudEvent event = EventMeshTestUtils.generateCloudEventV1Async(); + logger.info("begin send async msg[{}]==================={}", i, event); + client.publish(event, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); Thread.sleep(1000); } - Thread.sleep(2000); - // release resource and close client - // client.close(); } catch (Exception e) { logger.warn("AsyncPublish failed", e); } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/cloudevents/SyncRequest.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/cloudevents/SyncRequest.java new file mode 100644 index 0000000000..c04d2a7a6a --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/cloudevents/SyncRequest.java @@ -0,0 +1,70 @@ +/* + * Licensed 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.eventmesh.tcp.demo.pub.cloudevents; + +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPClientFactory; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.tcp.common.EventMeshTestUtils; +import org.apache.eventmesh.util.Utils; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.provider.EventFormatProvider; +import io.cloudevents.jackson.JsonFormat; +import lombok.extern.slf4j.Slf4j; + +import java.nio.charset.StandardCharsets; +import java.util.Properties; + +@Slf4j +public class SyncRequest { + + private static EventMeshTCPClient client; + + public static void main(String[] agrs) throws Exception { + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final int eventMeshTcpPort = Integer.parseInt(properties.getProperty("eventmesh.tcp.port")); + UserAgent userAgent = EventMeshTestUtils.generateClient1(); + EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder() + .host(eventMeshIp) + .port(eventMeshTcpPort) + .userAgent(userAgent) + .build(); + try { + client = EventMeshTCPClientFactory.createEventMeshTCPClient( + eventMeshTcpClientConfig, CloudEvent.class); + client.init(); + + CloudEvent event = EventMeshTestUtils.generateCloudEventV1SyncRR(); + log.info("begin send rr msg=================={}", event); + Package response = client.rr(event, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + CloudEvent replyEvent = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE) + .deserialize(response.getBody().toString().getBytes(StandardCharsets.UTF_8)); + String content = new String(replyEvent.getData().toBytes(), StandardCharsets.UTF_8); + log.info("receive rr reply==================={}|{}", response, content); + + } catch (Exception e) { + log.warn("SyncRequest failed", e); + } + } +} diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncPublish.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/eventmeshmessage/AsyncPublish.java similarity index 54% rename from eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncPublish.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/eventmeshmessage/AsyncPublish.java index ef9a3b6a14..a1687ce62e 100644 --- a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncPublish.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/eventmeshmessage/AsyncPublish.java @@ -15,14 +15,19 @@ * limitations under the License. */ -package org.apache.eventmesh.client.tcp.demo; +package org.apache.eventmesh.tcp.demo.pub.eventmeshmessage; -import org.apache.eventmesh.client.tcp.EventMeshClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.client.tcp.common.EventMeshTestUtils; -import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.EventMeshTCPClientFactory; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.tcp.common.EventMeshTestUtils; +import org.apache.eventmesh.util.Utils; + +import java.util.Properties; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,28 +35,34 @@ public class AsyncPublish { public static Logger logger = LoggerFactory.getLogger(AsyncPublish.class); - private static EventMeshClient client; + private static EventMeshTCPClient client; public static AsyncPublish handler = new AsyncPublish(); public static void main(String[] agrs) throws Exception { + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final int eventMeshTcpPort = Integer.parseInt(properties.getProperty("eventmesh.tcp.port")); try { UserAgent userAgent = EventMeshTestUtils.generateClient1(); - client = new DefaultEventMeshClient("127.0.0.1", 10002, userAgent); + EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder() + .host(eventMeshIp) + .port(eventMeshTcpPort) + .userAgent(userAgent) + .build(); + client = + EventMeshTCPClientFactory.createEventMeshTCPClient(eventMeshTcpClientConfig, EventMeshMessage.class); client.init(); - client.heartbeat(); for (int i = 0; i < 5; i++) { - Package asyncMsg = EventMeshTestUtils.asyncMessage(); - logger.info("begin send async msg[{}]==================={}", i, asyncMsg); - client.publish(asyncMsg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + EventMeshMessage eventMeshMessage = EventMeshTestUtils.generateAsyncEventMqMsg(); + + logger.info("begin send async msg[{}]==================={}", i, eventMeshMessage); + client.publish(eventMeshMessage, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); Thread.sleep(1000); } - Thread.sleep(2000); - // release resource and close client - // client.close(); } catch (Exception e) { logger.warn("AsyncPublish failed", e); } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/AsyncPublishBroadcast.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/eventmeshmessage/AsyncPublishBroadcast.java similarity index 64% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/AsyncPublishBroadcast.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/eventmeshmessage/AsyncPublishBroadcast.java index 4803daec19..e2d2634172 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/AsyncPublishBroadcast.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/eventmeshmessage/AsyncPublishBroadcast.java @@ -15,17 +15,19 @@ * limitations under the License. */ -package org.apache.eventmesh.tcp.demo; +package org.apache.eventmesh.tcp.demo.pub.eventmeshmessage; -import java.util.Properties; - -import org.apache.eventmesh.client.tcp.EventMeshClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.EventMeshTCPClientFactory; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.tcp.common.EventMeshTestUtils; import org.apache.eventmesh.util.Utils; + +import java.util.Properties; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,25 +35,26 @@ public class AsyncPublishBroadcast { public static Logger logger = LoggerFactory.getLogger(AsyncPublishBroadcast.class); - private static EventMeshClient client; - public static void main(String[] agrs) throws Exception { Properties properties = Utils.readPropertiesFile("application.properties"); final String eventMeshIp = properties.getProperty("eventmesh.ip"); final int eventMeshTcpPort = Integer.parseInt(properties.getProperty("eventmesh.tcp.port")); - try { - UserAgent userAgent = EventMeshTestUtils.generateClient1(); - client = new DefaultEventMeshClient(eventMeshIp, eventMeshTcpPort, userAgent); + UserAgent userAgent = EventMeshTestUtils.generateClient1(); + EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder() + .host(eventMeshIp) + .port(eventMeshTcpPort) + .userAgent(userAgent) + .build(); + try (final EventMeshTCPClient client = + EventMeshTCPClientFactory.createEventMeshTCPClient(eventMeshTcpClientConfig, EventMeshMessage.class)) { client.init(); - client.heartbeat(); - Package broadcastMsg = EventMeshTestUtils.broadcastMessage(); - logger.info("begin send broadcast msg============={}", broadcastMsg); - client.broadcast(broadcastMsg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + EventMeshMessage eventMeshMessage = EventMeshTestUtils.generateBroadcastMqMsg(); + logger.info("begin send broadcast msg============={}", eventMeshMessage); + client.broadcast(eventMeshMessage, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); Thread.sleep(2000); - // release resource and close client - // client.close(); + } catch (Exception e) { logger.warn("AsyncPublishBroadcast failed", e); } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/eventmeshmessage/SyncRequest.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/eventmeshmessage/SyncRequest.java new file mode 100644 index 0000000000..f0ded1fd93 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/pub/eventmeshmessage/SyncRequest.java @@ -0,0 +1,57 @@ +/* + * Licensed 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.eventmesh.tcp.demo.pub.eventmeshmessage; + +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.EventMeshTCPClientFactory; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.tcp.common.EventMeshTestUtils; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class SyncRequest { + + private static EventMeshTCPClient client; + + public static void main(String[] agrs) throws Exception { + UserAgent userAgent = EventMeshTestUtils.generateClient1(); + EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder() + .host("127.0.0.1") + .port(10002) + .userAgent(userAgent) + .build(); + try { + client = EventMeshTCPClientFactory.createEventMeshTCPClient( + eventMeshTcpClientConfig, EventMeshMessage.class); + client.init(); + + EventMeshMessage eventMeshMessage = EventMeshTestUtils.generateSyncRRMqMsg(); + log.info("begin send rr msg=================={}", eventMeshMessage); + Package response = client.rr(eventMeshMessage, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + log.info("receive rr reply==================={}", response); + + } catch (Exception e) { + log.warn("SyncRequest failed", e); + } + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/cloudevents/AsyncSubscribe.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/cloudevents/AsyncSubscribe.java new file mode 100644 index 0000000000..91f4eda6c8 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/cloudevents/AsyncSubscribe.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.eventmesh.tcp.demo.sub.cloudevents; + +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.EventMeshTCPClientFactory; +import org.apache.eventmesh.common.protocol.SubscriptionMode; +import org.apache.eventmesh.common.protocol.SubscriptionType; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.tcp.common.EventMeshTestCaseTopicSet; +import org.apache.eventmesh.tcp.common.EventMeshTestUtils; +import org.apache.eventmesh.util.Utils; + +import java.nio.charset.StandardCharsets; +import java.util.Optional; +import java.util.Properties; + +import io.cloudevents.CloudEvent; +import io.netty.channel.ChannelHandlerContext; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class AsyncSubscribe implements ReceiveMsgHook { + + public static AsyncSubscribe handler = new AsyncSubscribe(); + + private static EventMeshTCPClient client; + + public static void main(String[] agrs) throws Exception { + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final int eventMeshTcpPort = Integer.parseInt(properties.getProperty("eventmesh.tcp.port")); + UserAgent userAgent = EventMeshTestUtils.generateClient2(); + EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder() + .host(eventMeshIp) + .port(eventMeshTcpPort) + .userAgent(userAgent) + .build(); + try { + client = EventMeshTCPClientFactory.createEventMeshTCPClient(eventMeshTcpClientConfig, CloudEvent.class); + client.init(); + + client.subscribe(EventMeshTestCaseTopicSet.TOPIC_PRX_WQ2ClientUniCast, SubscriptionMode.CLUSTERING, SubscriptionType.ASYNC); + client.registerSubBusiHandler(handler); + + client.listen(); + + //client.unsubscribe(); + + // release resource and close client + // client.close(); + + } catch (Exception e) { + log.warn("AsyncSubscribe failed", e); + } + } + + @Override + public Optional handle(CloudEvent msg) { + String content = new String(msg.getData().toBytes(), StandardCharsets.UTF_8); + log.info("receive async msg====================={}|{}", msg, content); + return Optional.empty(); + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/cloudevents/SyncResponse.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/cloudevents/SyncResponse.java new file mode 100644 index 0000000000..d1753233f2 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/cloudevents/SyncResponse.java @@ -0,0 +1,82 @@ +/* + * Licensed 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.eventmesh.tcp.demo.sub.cloudevents; + +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPClientFactory; +import org.apache.eventmesh.client.tcp.common.MessageUtils; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.common.protocol.SubscriptionMode; +import org.apache.eventmesh.common.protocol.SubscriptionType; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.tcp.common.EventMeshTestUtils; +import org.apache.eventmesh.util.Utils; + +import io.cloudevents.CloudEvent; +import io.netty.channel.ChannelHandlerContext; +import lombok.extern.slf4j.Slf4j; + +import java.nio.charset.StandardCharsets; +import java.util.Optional; +import java.util.Properties; + +@Slf4j +public class SyncResponse implements ReceiveMsgHook { + + public static SyncResponse handler = new SyncResponse(); + + private static EventMeshTCPClient client; + + public static void main(String[] agrs) throws Exception { + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final int eventMeshTcpPort = Integer.parseInt(properties.getProperty("eventmesh.tcp.port")); + UserAgent userAgent = EventMeshTestUtils.generateClient2(); + EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder() + .host(eventMeshIp) + .port(eventMeshTcpPort) + .userAgent(userAgent) + .build(); + try { + client = EventMeshTCPClientFactory + .createEventMeshTCPClient(eventMeshTcpClientConfig, CloudEvent.class); + client.init(); + + client.subscribe("TEST-TOPIC-TCP-SYNC", SubscriptionMode.CLUSTERING, SubscriptionType.SYNC); + // Synchronize RR messages + client.registerSubBusiHandler(handler); + + client.listen(); + + } catch (Exception e) { + log.warn("SyncResponse failed", e); + } + } + + @Override + public Optional handle(CloudEvent event) { + String content = new String(event.getData().toBytes(), StandardCharsets.UTF_8); + log.info("receive sync rr msg================{}|{}", event, content); + return Optional.of(event); + } + +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/AsyncSubscribe.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/eventmeshmessage/AsyncSubscribe.java similarity index 60% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/AsyncSubscribe.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/eventmeshmessage/AsyncSubscribe.java index 769fd22268..bb99cfc7f5 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/AsyncSubscribe.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/eventmeshmessage/AsyncSubscribe.java @@ -15,44 +15,50 @@ * limitations under the License. */ -package org.apache.eventmesh.tcp.demo; +package org.apache.eventmesh.tcp.demo.sub.eventmeshmessage; -import java.util.Properties; - -import io.netty.channel.ChannelHandlerContext; - -import org.apache.eventmesh.client.tcp.EventMeshClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; -import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.EventMeshTCPClientFactory; +import org.apache.eventmesh.common.protocol.SubscriptionMode; import org.apache.eventmesh.common.protocol.SubscriptionType; import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.apache.eventmesh.common.protocol.SubscriptionMode; import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.tcp.common.EventMeshTestCaseTopicSet; import org.apache.eventmesh.tcp.common.EventMeshTestUtils; import org.apache.eventmesh.util.Utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -public class AsyncSubscribe implements ReceiveMsgHook { +import java.util.Optional; +import java.util.Properties; - public static Logger logger = LoggerFactory.getLogger(AsyncSubscribe.class); +import io.netty.channel.ChannelHandlerContext; +import lombok.extern.slf4j.Slf4j; - private static EventMeshClient client; +@Slf4j +public class AsyncSubscribe implements ReceiveMsgHook { public static AsyncSubscribe handler = new AsyncSubscribe(); + private static EventMeshTCPClient client; + public static void main(String[] agrs) throws Exception { Properties properties = Utils.readPropertiesFile("application.properties"); final String eventMeshIp = properties.getProperty("eventmesh.ip"); final int eventMeshTcpPort = Integer.parseInt(properties.getProperty("eventmesh.tcp.port")); + UserAgent userAgent = EventMeshTestUtils.generateClient2(); + EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder() + .host(eventMeshIp) + .port(eventMeshTcpPort) + .userAgent(userAgent) + .build(); try { - UserAgent userAgent = EventMeshTestUtils.generateClient2(); - client = new DefaultEventMeshClient(eventMeshIp, eventMeshTcpPort, userAgent); + client = + EventMeshTCPClientFactory.createEventMeshTCPClient(eventMeshTcpClientConfig, EventMeshMessage.class); client.init(); - client.heartbeat(); - client.subscribe("TEST-TOPIC-TCP-ASYNC", SubscriptionMode.CLUSTERING, SubscriptionType.ASYNC); + client.subscribe(EventMeshTestCaseTopicSet.TOPIC_PRX_WQ2ClientUniCast, SubscriptionMode.CLUSTERING, + SubscriptionType.ASYNC); client.registerSubBusiHandler(handler); client.listen(); @@ -61,14 +67,15 @@ public static void main(String[] agrs) throws Exception { // release resource and close client // client.close(); + } catch (Exception e) { - logger.warn("AsyncSubscribe failed", e); + log.warn("AsyncSubscribe failed", e); } } @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - EventMeshMessage eventMeshMessage = (EventMeshMessage) msg.getBody(); - logger.info("receive async msg====================={}", eventMeshMessage); + public Optional handle(EventMeshMessage msg) { + log.info("receive async msg====================={}", msg); + return Optional.empty(); } } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/AsyncSubscribeBroadcast.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/eventmeshmessage/AsyncSubscribeBroadcast.java similarity index 64% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/AsyncSubscribeBroadcast.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/eventmeshmessage/AsyncSubscribeBroadcast.java index 99735487bc..dfc58a5a62 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/AsyncSubscribeBroadcast.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/eventmeshmessage/AsyncSubscribeBroadcast.java @@ -15,30 +15,27 @@ * limitations under the License. */ -package org.apache.eventmesh.tcp.demo; +package org.apache.eventmesh.tcp.demo.sub.eventmeshmessage; -import java.util.Properties; - -import io.netty.channel.ChannelHandlerContext; - -import org.apache.eventmesh.client.tcp.EventMeshClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; -import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.EventMeshTCPClientFactory; +import org.apache.eventmesh.common.protocol.SubscriptionMode; import org.apache.eventmesh.common.protocol.SubscriptionType; import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.apache.eventmesh.common.protocol.SubscriptionMode; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.tcp.common.EventMeshTestUtils; import org.apache.eventmesh.util.Utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -public class AsyncSubscribeBroadcast implements ReceiveMsgHook { +import java.util.Optional; +import java.util.Properties; - public static Logger logger = LoggerFactory.getLogger(AsyncSubscribeBroadcast.class); +import io.netty.channel.ChannelHandlerContext; +import lombok.extern.slf4j.Slf4j; - private static EventMeshClient client; +@Slf4j +public class AsyncSubscribeBroadcast implements ReceiveMsgHook { public static AsyncSubscribeBroadcast handler = new AsyncSubscribeBroadcast(); @@ -46,29 +43,30 @@ public static void main(String[] agrs) throws Exception { Properties properties = Utils.readPropertiesFile("application.properties"); final String eventMeshIp = properties.getProperty("eventmesh.ip"); final int eventMeshTcpPort = Integer.parseInt(properties.getProperty("eventmesh.tcp.port")); - try { - UserAgent userAgent = EventMeshTestUtils.generateClient2(); - client = new DefaultEventMeshClient(eventMeshIp, eventMeshTcpPort, userAgent); + UserAgent userAgent = EventMeshTestUtils.generateClient2(); + EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder() + .host(eventMeshIp) + .port(eventMeshTcpPort) + .userAgent(userAgent) + .build(); + try (EventMeshTCPClient client = EventMeshTCPClientFactory.createEventMeshTCPClient( + eventMeshTcpClientConfig, EventMeshMessage.class)) { client.init(); - client.heartbeat(); client.subscribe("TEST-TOPIC-TCP-BROADCAST", SubscriptionMode.BROADCASTING, SubscriptionType.ASYNC); client.registerSubBusiHandler(handler); client.listen(); - //client.unsubscribe(); - - // release resource and close client - // client.close(); } catch (Exception e) { - logger.warn("AsyncSubscribeBroadcast failed", e); + log.warn("AsyncSubscribeBroadcast failed", e); } } @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - EventMeshMessage eventMeshMessage = (EventMeshMessage) msg.getBody(); - logger.info("receive broadcast msg==============={}", eventMeshMessage); + public Optional handle(EventMeshMessage msg) { + log.info("receive broadcast msg==============={}", msg); + return Optional.empty(); } + } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/SyncResponse.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/eventmeshmessage/SyncResponse.java similarity index 55% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/SyncResponse.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/eventmeshmessage/SyncResponse.java index 033dfb43ef..e9606fa6ce 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/SyncResponse.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/tcp/demo/sub/eventmeshmessage/SyncResponse.java @@ -15,35 +15,45 @@ * limitations under the License. */ -package org.apache.eventmesh.tcp.demo; +package org.apache.eventmesh.tcp.demo.sub.eventmeshmessage; -import io.netty.channel.ChannelHandlerContext; - -import org.apache.eventmesh.client.tcp.EventMeshClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; +import org.apache.eventmesh.client.tcp.common.MessageUtils; import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; -import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.EventMeshTCPClientFactory; +import org.apache.eventmesh.common.protocol.SubscriptionMode; import org.apache.eventmesh.common.protocol.SubscriptionType; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; import org.apache.eventmesh.common.protocol.tcp.Package; -import org.apache.eventmesh.common.protocol.SubscriptionMode; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.tcp.common.EventMeshTestUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -public class SyncResponse implements ReceiveMsgHook { +import io.netty.channel.ChannelHandlerContext; +import lombok.extern.slf4j.Slf4j; +import static org.apache.eventmesh.common.protocol.tcp.Command.RESPONSE_TO_SERVER; - public static Logger logger = LoggerFactory.getLogger(SyncResponse.class); +import java.util.Optional; - private static EventMeshClient client; +@Slf4j +public class SyncResponse implements ReceiveMsgHook { public static SyncResponse handler = new SyncResponse(); + private static EventMeshTCPClient client; + public static void main(String[] agrs) throws Exception { + UserAgent userAgent = EventMeshTestUtils.generateClient2(); + EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder() + .host("127.0.0.1") + .port(10002) + .userAgent(userAgent) + .build(); try { - UserAgent userAgent = EventMeshTestUtils.generateClient2(); - client = new DefaultEventMeshClient("127.0.0.1", 10000, userAgent); + client = EventMeshTCPClientFactory + .createEventMeshTCPClient(eventMeshTcpClientConfig, EventMeshMessage.class); client.init(); - client.heartbeat(); client.subscribe("TEST-TOPIC-TCP-SYNC", SubscriptionMode.CLUSTERING, SubscriptionType.SYNC); // Synchronize RR messages @@ -51,19 +61,15 @@ public static void main(String[] agrs) throws Exception { client.listen(); - //client.unsubscribe(); - - // release resource and close client - // client.close(); } catch (Exception e) { - logger.warn("SyncResponse failed", e); + log.warn("SyncResponse failed", e); } } @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - logger.info("receive sync rr msg================{}", msg); - Package pkg = EventMeshTestUtils.rrResponse(msg); - ctx.writeAndFlush(pkg); + public Optional handle(EventMeshMessage msg) { + log.info("receive sync rr msg================{}", msg); + return Optional.ofNullable(msg); } + } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/util/Utils.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/util/Utils.java index 6911a4388b..63a93ba759 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/util/Utils.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/util/Utils.java @@ -17,6 +17,9 @@ package org.apache.eventmesh.util; +import org.apache.commons.lang3.SystemUtils; + +import java.io.InputStream; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; @@ -24,10 +27,6 @@ import java.util.Enumeration; import java.util.Properties; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.core.io.support.PropertiesLoaderUtils; - public class Utils { /** @@ -49,13 +48,7 @@ public static String getLocalIP() throws UnknownHostException, SocketException { * @return */ public static boolean isWindowsOS() { - boolean isWindowsOS = false; - // JRE (runtime)system,not OS - String osName = System.getProperty("os.name"); - if (osName.toLowerCase().contains("windows")) { - isWindowsOS = true; - } - return isWindowsOS; + return SystemUtils.IS_OS_WINDOWS; } /** @@ -71,12 +64,13 @@ private static String getLinuxLocalIp() throws SocketException { NetworkInterface intf = en.nextElement(); String name = intf.getName(); if (!name.contains("docker") && !name.contains("lo")) { - for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) { + for (Enumeration enumIpAddr = intf.getInetAddresses(); + enumIpAddr.hasMoreElements(); ) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress()) { String ipaddress = inetAddress.getHostAddress().toString(); if (!ipaddress.contains("::") && !ipaddress.contains("0:0:") - && !ipaddress.contains("fe80")) { + && !ipaddress.contains("fe80")) { ip = ipaddress; } } @@ -92,17 +86,16 @@ private static String getLinuxLocalIp() throws SocketException { /** * @param fileName - * @return + * @return Properties */ public static Properties readPropertiesFile(String fileName) { - try { - Resource resource = new ClassPathResource(fileName); - Properties props = PropertiesLoaderUtils.loadProperties(resource); - return props; + try (final InputStream inputStream = Utils.class.getClassLoader().getResourceAsStream(fileName)) { + Properties properties = new Properties(); + properties.load(inputStream); + return properties; } catch (Exception e) { - e.printStackTrace(); + throw new IllegalArgumentException(String.format("File: %s is not exist", fileName)); } - return null; } } diff --git a/eventmesh-examples/src/main/resources/application.properties b/eventmesh-examples/src/main/resources/application.properties index 8289cb6b01..51640d82b3 100644 --- a/eventmesh-examples/src/main/resources/application.properties +++ b/eventmesh-examples/src/main/resources/application.properties @@ -17,4 +17,5 @@ server.port=8088 eventmesh.ip=127.0.0.1 eventmesh.http.port=10105 -eventmesh.tcp.port=10000 \ No newline at end of file +eventmesh.tcp.port=10000 +eventmesh.grpc.port=10205 \ No newline at end of file diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-api/build.gradle b/eventmesh-protocol-plugin/eventmesh-protocol-api/build.gradle index c251936ad5..feb34b0d2f 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-api/build.gradle +++ b/eventmesh-protocol-plugin/eventmesh-protocol-api/build.gradle @@ -16,8 +16,8 @@ */ dependencies { - implementation project(":eventmesh-spi") - implementation project(":eventmesh-common") + api project(":eventmesh-spi") + api project(":eventmesh-common") implementation "io.cloudevents:cloudevents-core" @@ -26,4 +26,10 @@ dependencies { testImplementation "io.cloudevents:cloudevents-core" testImplementation "junit:junit" + + compileOnly 'org.projectlombok:lombok:1.18.22' + annotationProcessor 'org.projectlombok:lombok:1.18.22' + + testCompileOnly 'org.projectlombok:lombok:1.18.22' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' } \ No newline at end of file diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolAdaptor.java b/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolAdaptor.java index 77ca725599..43ba72401b 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolAdaptor.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolAdaptor.java @@ -17,12 +17,14 @@ package org.apache.eventmesh.protocol.api; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; import org.apache.eventmesh.spi.EventMeshExtensionType; import org.apache.eventmesh.spi.EventMeshSPI; import io.cloudevents.CloudEvent; -import io.cloudevents.core.v1.CloudEventV1; + +import java.util.List; /** * Protocol transformer SPI interface, all protocol plugin should implementation. @@ -32,7 +34,7 @@ * @since 1.3.0 */ @EventMeshSPI(isSingleton = true, eventMeshExtensionType = EventMeshExtensionType.PROTOCOL) -public interface ProtocolAdaptor { +public interface ProtocolAdaptor { /** * transform protocol to {@link CloudEvent}. @@ -40,8 +42,15 @@ public interface ProtocolAdaptor { * @param protocol input protocol * @return cloud event */ - CloudEventV1 toCloudEventV1(Package protocol) throws ProtocolHandleException; + CloudEvent toCloudEvent(T protocol) throws ProtocolHandleException; + /** + * transform protocol to {@link CloudEvent} list. + * + * @param protocol input protocol + * @return list cloud event + */ + List toBatchCloudEvent(T protocol) throws ProtocolHandleException; /** * Transform {@link CloudEvent} to target protocol. @@ -49,7 +58,7 @@ public interface ProtocolAdaptor { * @param cloudEvent clout event * @return target protocol */ - Package fromCloudEventV1(CloudEventV1 cloudEvent) throws ProtocolHandleException; + ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleException; /** * Get protocol type. diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolPluginFactory.java b/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolPluginFactory.java index f9208ee9b6..2d6f7bd559 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolPluginFactory.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-api/src/main/java/org/apache/eventmesh/protocol/api/ProtocolPluginFactory.java @@ -17,20 +17,23 @@ package org.apache.eventmesh.protocol.api; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; import org.apache.eventmesh.spi.EventMeshExtensionFactory; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import lombok.experimental.UtilityClass; + /** * A factory to get Protocol plugin instance. * * @since 1.3.0 */ -public enum ProtocolPluginFactory { - ; +@UtilityClass +public class ProtocolPluginFactory { - private static final Map PROTOCOL_ADAPTOR_MAP = + private static final Map> PROTOCOL_ADAPTOR_MAP = new ConcurrentHashMap<>(16); /** @@ -40,8 +43,9 @@ public enum ProtocolPluginFactory { * @return protocol adaptor * @throws IllegalArgumentException if protocol not found */ - public static ProtocolAdaptor getProtocolAdaptor(String protocolType) { - ProtocolAdaptor protocolAdaptor = PROTOCOL_ADAPTOR_MAP.computeIfAbsent( + @SuppressWarnings("unchecked") + public static ProtocolAdaptor getProtocolAdaptor(String protocolType) { + ProtocolAdaptor protocolAdaptor = PROTOCOL_ADAPTOR_MAP.computeIfAbsent( protocolType, (type) -> EventMeshExtensionFactory.getExtension(ProtocolAdaptor.class, type) ); diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/build.gradle b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/build.gradle index 4a82353e6e..7f77c3db21 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/build.gradle +++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/build.gradle @@ -16,10 +16,10 @@ */ dependencies { - compileOnly project(":eventmesh-protocol-plugin:eventmesh-protocol-api") + implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api") implementation "io.cloudevents:cloudevents-core" + implementation "com.google.guava:guava" + implementation "io.cloudevents:cloudevents-json-jackson" - testImplementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api") - testImplementation "io.cloudevents:cloudevents-core" testImplementation "junit:junit" } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptor.java b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptor.java index 0466896190..10939ee679 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptor.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptor.java @@ -17,27 +17,125 @@ package org.apache.eventmesh.protocol.cloudevents; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.http.HttpCommand; +import org.apache.eventmesh.common.protocol.http.body.Body; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.protocol.tcp.Header; +import org.apache.eventmesh.common.protocol.tcp.Package; import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; +import org.apache.eventmesh.protocol.cloudevents.resolver.http.SendMessageBatchProtocolResolver; +import org.apache.eventmesh.protocol.cloudevents.resolver.http.SendMessageBatchV2ProtocolResolver; +import org.apache.eventmesh.protocol.cloudevents.resolver.http.SendMessageRequestProtocolResolver; +import org.apache.eventmesh.protocol.cloudevents.resolver.tcp.TcpMessageProtocolResolver; -import io.cloudevents.core.v1.CloudEventV1; +import org.apache.commons.lang3.StringUtils; + +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.common.base.Preconditions; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.format.EventFormat; +import io.cloudevents.core.provider.EventFormatProvider; +import io.cloudevents.jackson.JsonFormat; /** * CloudEvents protocol adaptor, used to transform CloudEvents message to CloudEvents message. * * @since 1.3.0 */ -public class CloudEventsProtocolAdaptor implements ProtocolAdaptor { +public class CloudEventsProtocolAdaptor + implements ProtocolAdaptor { @Override - public CloudEventV1 toCloudEventV1(Package cloudEvent) { - return null; + public CloudEvent toCloudEvent(ProtocolTransportObject cloudEvent) throws ProtocolHandleException { + + if (cloudEvent instanceof Package) { + Package tcpPackage = (Package) cloudEvent; + Header header = tcpPackage.getHeader(); + String cloudEventJson = tcpPackage.getBody().toString(); + + return deserializeTcpProtocol(header, cloudEventJson); + + } else if (cloudEvent instanceof HttpCommand) { + org.apache.eventmesh.common.protocol.http.header.Header header = ((HttpCommand) cloudEvent).getHeader(); + Body body = ((HttpCommand) cloudEvent).getBody(); + String requestCode = ((HttpCommand) cloudEvent).getRequestCode(); + + return deserializeHttpProtocol(requestCode, header, body); + } else { + throw new ProtocolHandleException(String.format("protocol class: %s", cloudEvent.getClass())); + } + } + + private CloudEvent deserializeTcpProtocol(Header header, String cloudEventJson) throws ProtocolHandleException { + return TcpMessageProtocolResolver.buildEvent(header, cloudEventJson); + } + + private CloudEvent deserializeHttpProtocol(String requestCode, + org.apache.eventmesh.common.protocol.http.header.Header header, + Body body) throws ProtocolHandleException { + + if (String.valueOf(RequestCode.MSG_BATCH_SEND.getRequestCode()).equals(requestCode)) { + return SendMessageBatchProtocolResolver.buildEvent(header, body); + } else if (String.valueOf(RequestCode.MSG_BATCH_SEND_V2.getRequestCode()).equals(requestCode)) { + return SendMessageBatchV2ProtocolResolver.buildEvent(header, body); + } else if (String.valueOf(RequestCode.MSG_SEND_SYNC.getRequestCode()).equals(requestCode)) { + return SendMessageRequestProtocolResolver.buildEvent(header, body); + } else if (String.valueOf(RequestCode.MSG_SEND_ASYNC.getRequestCode()).equals(requestCode)) { + return SendMessageRequestProtocolResolver.buildEvent(header, body); + } else { + throw new ProtocolHandleException(String.format("unsupported requestCode: %s", requestCode)); + } + } @Override - public Package fromCloudEventV1(CloudEventV1 cloudEvent) { + public List toBatchCloudEvent(ProtocolTransportObject protocol) + throws ProtocolHandleException { return null; } + @Override + public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleException { + String protocolDesc = cloudEvent.getExtension(Constants.PROTOCOL_DESC).toString(); + if (StringUtils.equals("http", protocolDesc)) { + HttpCommand httpCommand = new HttpCommand(); + Body body = new Body() { + final Map map = new HashMap<>(); + + @Override + public Map toMap() { + byte[] eventByte = + EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE).serialize(cloudEvent); + map.put("content", new String(eventByte, StandardCharsets.UTF_8)); + return map; + } + }; + body.toMap(); + httpCommand.setBody(body); + return httpCommand; + } else if (StringUtils.equals("tcp", protocolDesc)) { + Package pkg = new Package(); + String dataContentType = cloudEvent.getDataContentType(); + Preconditions.checkNotNull(dataContentType, "DateContentType cannot be null"); + EventFormat eventFormat = EventFormatProvider.getInstance().resolveFormat(dataContentType); + Preconditions.checkNotNull(eventFormat, + String.format("DateContentType:%s is not supported", dataContentType)); + pkg.setBody(eventFormat.serialize(cloudEvent)); + return pkg; + } else { + throw new ProtocolHandleException(String.format("Unsupported protocolDesc: %s", protocolDesc)); + } + + } + @Override public String getProtocolType() { return CloudEventsProtocolConstant.PROTOCOL_NAME; diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/http/SendMessageBatchProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/http/SendMessageBatchProtocolResolver.java new file mode 100644 index 0000000000..2b4f180038 --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/http/SendMessageBatchProtocolResolver.java @@ -0,0 +1,28 @@ +/* + * Licensed 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.eventmesh.protocol.cloudevents.resolver.http; + +import io.cloudevents.CloudEvent; +import org.apache.eventmesh.common.protocol.http.body.Body; +import org.apache.eventmesh.common.protocol.http.header.Header; + +public class SendMessageBatchProtocolResolver { + public static CloudEvent buildEvent(Header header, Body body) { + return null; + } +} diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/http/SendMessageBatchV2ProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/http/SendMessageBatchV2ProtocolResolver.java new file mode 100644 index 0000000000..a90484b060 --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/http/SendMessageBatchV2ProtocolResolver.java @@ -0,0 +1,111 @@ +/* + * Licensed 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.eventmesh.protocol.cloudevents.resolver.http; + +import io.cloudevents.CloudEvent; +import io.cloudevents.SpecVersion; +import io.cloudevents.core.builder.CloudEventBuilder; +import io.cloudevents.core.provider.EventFormatProvider; +import io.cloudevents.core.v03.CloudEventV03; +import io.cloudevents.core.v1.CloudEventV1; +import io.cloudevents.jackson.JsonFormat; + +import org.apache.commons.lang3.StringUtils; + +import org.apache.eventmesh.common.protocol.http.body.Body; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchV2RequestBody; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; +import org.apache.eventmesh.common.protocol.http.header.Header; +import org.apache.eventmesh.common.protocol.http.header.message.SendMessageBatchV2RequestHeader; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; + +import java.nio.charset.StandardCharsets; + +public class SendMessageBatchV2ProtocolResolver { + public static CloudEvent buildEvent(Header header, Body body) throws ProtocolHandleException { + try { + SendMessageBatchV2RequestHeader sendMessageBatchV2RequestHeader = (SendMessageBatchV2RequestHeader) header; + SendMessageBatchV2RequestBody sendMessageBatchV2RequestBody = (SendMessageBatchV2RequestBody) body; + + String protocolType = sendMessageBatchV2RequestHeader.getProtocolType(); + String protocolDesc = sendMessageBatchV2RequestHeader.getProtocolDesc(); + String protocolVersion = sendMessageBatchV2RequestHeader.getProtocolVersion(); + + String code = sendMessageBatchV2RequestHeader.getCode(); + String env = sendMessageBatchV2RequestHeader.getEnv(); + String idc = sendMessageBatchV2RequestHeader.getIdc(); + String ip = sendMessageBatchV2RequestHeader.getIp(); + String pid = sendMessageBatchV2RequestHeader.getPid(); + String sys = sendMessageBatchV2RequestHeader.getSys(); + String username = sendMessageBatchV2RequestHeader.getUsername(); + String passwd = sendMessageBatchV2RequestHeader.getPasswd(); + ProtocolVersion version = sendMessageBatchV2RequestHeader.getVersion(); + String language = sendMessageBatchV2RequestHeader.getLanguage(); + + String producerGroup = sendMessageBatchV2RequestBody.getProducerGroup(); + String content = sendMessageBatchV2RequestBody.getMsg(); + + CloudEvent event = null; + if (StringUtils.equals(SpecVersion.V1.toString(), protocolVersion)) { + event = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE) + .deserialize(content.getBytes(StandardCharsets.UTF_8)); + event = CloudEventBuilder.from(event) + .withExtension(ProtocolKey.REQUEST_CODE, code) + .withExtension(ProtocolKey.ClientInstanceKey.ENV, env) + .withExtension(ProtocolKey.ClientInstanceKey.IDC, idc) + .withExtension(ProtocolKey.ClientInstanceKey.IP, ip) + .withExtension(ProtocolKey.ClientInstanceKey.PID, pid) + .withExtension(ProtocolKey.ClientInstanceKey.SYS, sys) + .withExtension(ProtocolKey.ClientInstanceKey.USERNAME, username) + .withExtension(ProtocolKey.ClientInstanceKey.PASSWD, passwd) + .withExtension(ProtocolKey.VERSION, version.getVersion()) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(SendMessageBatchV2RequestBody.PRODUCERGROUP, producerGroup) + .build(); + } else if (StringUtils.equals(SpecVersion.V03.toString(), protocolVersion)) { + event = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE) + .deserialize(content.getBytes(StandardCharsets.UTF_8)); + event = CloudEventBuilder.from(event) + .withExtension(ProtocolKey.REQUEST_CODE, code) + .withExtension(ProtocolKey.ClientInstanceKey.ENV, env) + .withExtension(ProtocolKey.ClientInstanceKey.IDC, idc) + .withExtension(ProtocolKey.ClientInstanceKey.IP, ip) + .withExtension(ProtocolKey.ClientInstanceKey.PID, pid) + .withExtension(ProtocolKey.ClientInstanceKey.SYS, sys) + .withExtension(ProtocolKey.ClientInstanceKey.USERNAME, username) + .withExtension(ProtocolKey.ClientInstanceKey.PASSWD, passwd) + .withExtension(ProtocolKey.VERSION, version.getVersion()) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(SendMessageBatchV2RequestBody.PRODUCERGROUP, producerGroup) + .build(); + } + return event; + } catch (Exception e) { + throw new ProtocolHandleException(e.getMessage(), e.getCause()); + } + } +} diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/http/SendMessageRequestProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/http/SendMessageRequestProtocolResolver.java new file mode 100644 index 0000000000..f8e0791e6d --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/http/SendMessageRequestProtocolResolver.java @@ -0,0 +1,110 @@ +/* + * Licensed 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.eventmesh.protocol.cloudevents.resolver.http; + +import io.cloudevents.CloudEvent; +import io.cloudevents.SpecVersion; +import io.cloudevents.core.builder.CloudEventBuilder; +import io.cloudevents.core.provider.EventFormatProvider; +import io.cloudevents.core.v03.CloudEventV03; +import io.cloudevents.core.v1.CloudEventV1; +import io.cloudevents.jackson.JsonFormat; + +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.protocol.http.body.Body; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; +import org.apache.eventmesh.common.protocol.http.header.Header; +import org.apache.eventmesh.common.protocol.http.header.message.SendMessageRequestHeader; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; + +import java.nio.charset.StandardCharsets; + +public class SendMessageRequestProtocolResolver { + + public static CloudEvent buildEvent(Header header, Body body) throws ProtocolHandleException { + try { + SendMessageRequestHeader sendMessageRequestHeader = (SendMessageRequestHeader) header; + SendMessageRequestBody sendMessageRequestBody = (SendMessageRequestBody) body; + + String protocolType = sendMessageRequestHeader.getProtocolType(); + String protocolDesc = sendMessageRequestHeader.getProtocolDesc(); + String protocolVersion = sendMessageRequestHeader.getProtocolVersion(); + + String code = sendMessageRequestHeader.getCode(); + String env = sendMessageRequestHeader.getEnv(); + String idc = sendMessageRequestHeader.getIdc(); + String ip = sendMessageRequestHeader.getIp(); + String pid = sendMessageRequestHeader.getPid(); + String sys = sendMessageRequestHeader.getSys(); + String username = sendMessageRequestHeader.getUsername(); + String passwd = sendMessageRequestHeader.getPasswd(); + ProtocolVersion version = sendMessageRequestHeader.getVersion(); + String language = sendMessageRequestHeader.getLanguage(); + + String producerGroup = sendMessageRequestBody.getProducerGroup(); + String content = sendMessageRequestBody.getContent(); + + CloudEvent event = null; + if (StringUtils.equals(SpecVersion.V1.toString(), protocolVersion)) { + event = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE) + .deserialize(content.getBytes(StandardCharsets.UTF_8)); + event = CloudEventBuilder.v1(event) + .withExtension(ProtocolKey.REQUEST_CODE, code) + .withExtension(ProtocolKey.ClientInstanceKey.ENV, env) + .withExtension(ProtocolKey.ClientInstanceKey.IDC, idc) + .withExtension(ProtocolKey.ClientInstanceKey.IP, ip) + .withExtension(ProtocolKey.ClientInstanceKey.PID, pid) + .withExtension(ProtocolKey.ClientInstanceKey.SYS, sys) + .withExtension(ProtocolKey.ClientInstanceKey.USERNAME, username) + .withExtension(ProtocolKey.ClientInstanceKey.PASSWD, passwd) + .withExtension(ProtocolKey.VERSION, version.getVersion()) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(SendMessageRequestBody.PRODUCERGROUP, producerGroup) + .build(); + } else if (StringUtils.equals(SpecVersion.V03.toString(), protocolVersion)) { + event = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE) + .deserialize(content.getBytes(StandardCharsets.UTF_8)); + event = CloudEventBuilder.v03(event) + .withExtension(ProtocolKey.REQUEST_CODE, code) + .withExtension(ProtocolKey.ClientInstanceKey.ENV, env) + .withExtension(ProtocolKey.ClientInstanceKey.IDC, idc) + .withExtension(ProtocolKey.ClientInstanceKey.IP, ip) + .withExtension(ProtocolKey.ClientInstanceKey.PID, pid) + .withExtension(ProtocolKey.ClientInstanceKey.SYS, sys) + .withExtension(ProtocolKey.ClientInstanceKey.USERNAME, username) + .withExtension(ProtocolKey.ClientInstanceKey.PASSWD, passwd) + .withExtension(ProtocolKey.VERSION, version.getVersion()) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(SendMessageRequestBody.PRODUCERGROUP, producerGroup) + .build(); + } + return event; + } catch (Exception e) { + throw new ProtocolHandleException(e.getMessage(), e.getCause()); + } + } +} diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/tcp/TcpMessageProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/tcp/TcpMessageProtocolResolver.java new file mode 100644 index 0000000000..8903786296 --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/tcp/TcpMessageProtocolResolver.java @@ -0,0 +1,88 @@ +/* + * Licensed 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.eventmesh.protocol.cloudevents.resolver.tcp; + +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.tcp.Header; +import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; +import org.apache.eventmesh.protocol.cloudevents.CloudEventsProtocolConstant; + +import org.apache.commons.lang3.StringUtils; + +import java.nio.charset.StandardCharsets; + +import com.google.common.base.Preconditions; + +import io.cloudevents.CloudEvent; +import io.cloudevents.SpecVersion; +import io.cloudevents.core.builder.CloudEventBuilder; +import io.cloudevents.core.format.EventFormat; +import io.cloudevents.core.provider.EventFormatProvider; +import io.cloudevents.jackson.JsonFormat; + +public class TcpMessageProtocolResolver { + + public static CloudEvent buildEvent(Header header, String cloudEventJson) + throws ProtocolHandleException { + CloudEventBuilder cloudEventBuilder; + + String protocolType = header.getProperty(Constants.PROTOCOL_TYPE).toString(); + String protocolVersion = header.getProperty(Constants.PROTOCOL_VERSION).toString(); + String protocolDesc = header.getProperty(Constants.PROTOCOL_DESC).toString(); + + if (StringUtils.isBlank(protocolType) + || StringUtils.isBlank(protocolVersion) + || StringUtils.isBlank(protocolDesc)) { + throw new ProtocolHandleException( + String.format("invalid protocol params protocolType %s|protocolVersion %s|protocolDesc %s", + protocolType, protocolVersion, protocolDesc)); + } + + if (!StringUtils.equals(CloudEventsProtocolConstant.PROTOCOL_NAME, protocolType)) { + throw new ProtocolHandleException(String.format("Unsupported protocolType: %s", protocolType)); + } + + if (StringUtils.equals(SpecVersion.V1.toString(), protocolVersion)) { + // todo:resolve different format + EventFormat eventFormat = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE); + Preconditions + .checkNotNull(eventFormat, String.format("EventFormat: %s is not supported", JsonFormat.CONTENT_TYPE)); + CloudEvent event = eventFormat.deserialize(cloudEventJson.getBytes(StandardCharsets.UTF_8)); + cloudEventBuilder = CloudEventBuilder.v1(event); + for (String propKey : header.getProperties().keySet()) { + cloudEventBuilder.withExtension(propKey, header.getProperty(propKey).toString()); + } + + return cloudEventBuilder.build(); + + } else if (StringUtils.equals(SpecVersion.V03.toString(), protocolVersion)) { + // todo:resolve different format + CloudEvent event = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE) + .deserialize(cloudEventJson.getBytes(StandardCharsets.UTF_8)); + cloudEventBuilder = CloudEventBuilder.v03(event); + + for (String propKey : header.getProperties().keySet()) { + cloudEventBuilder.withExtension(propKey, header.getProperty(propKey).toString()); + } + + return cloudEventBuilder.build(); + } else { + throw new ProtocolHandleException(String.format("Unsupported protocolVersion: %s", protocolVersion)); + } + } +} diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/test/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptorTest.java b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/test/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptorTest.java index 7cbb9ab481..5155cf6e84 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/test/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptorTest.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/test/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptorTest.java @@ -17,6 +17,7 @@ package org.apache.eventmesh.protocol.cloudevents; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; import org.apache.eventmesh.protocol.api.ProtocolAdaptor; import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; @@ -27,7 +28,7 @@ public class CloudEventsProtocolAdaptorTest { @Test public void loadPlugin() { - ProtocolAdaptor protocolAdaptor = + ProtocolAdaptor protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(CloudEventsProtocolConstant.PROTOCOL_NAME); Assert.assertNotNull(protocolAdaptor); diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto index 1b2e3fa438..da4c61e935 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto +++ b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto @@ -17,11 +17,11 @@ syntax = "proto3"; -package eventmesh.client; +package eventmesh.common.protocol.grpc; option java_multiple_files = true; -option java_package = "org.apache.eventmesh.client.grpc.protos"; -option java_outer_classname = "EventmeshClient"; +option java_package = "org.apache.eventmesh.common.protocol.grpc.protos"; +option java_outer_classname = "EventmeshGrpc"; message RequestHeader { string env = 1; @@ -32,18 +32,21 @@ message RequestHeader { string sys = 6; string username = 7; string password = 8; - string version = 9; - string language = 10; - string seqNum = 11; + string language = 9; + string protocolType = 10; + string protocolVersion = 11; + string protocolDesc = 12; } -message Message { +message EventMeshMessage { RequestHeader header = 1; - string productionGroup = 2; + string producerGroup = 2; string topic = 3; string content = 4; string ttl = 5; string uniqueId = 6; + string seqNum = 7; + string tag = 8; } message Response { @@ -58,18 +61,33 @@ message Subscription { string consumerGroup = 2; message SubscriptionItem { + enum SubscriptionMode { + CLUSTERING = 0; + BROADCASTING = 1; + } + + enum SubscriptionType { + ASYNC = 0; + SYNC = 1; + } + string topic = 1; - string mode = 2; - string type = 3; - string url = 4; + SubscriptionMode mode = 2; + SubscriptionType type = 3; } repeated SubscriptionItem subscriptionItems = 3; + string url = 4; } message Heartbeat { + enum ClientType { + PUB = 0; + SUB = 1; + } + RequestHeader header = 1; - string clientType = 2; + ClientType clientType = 2; string producerGroup = 3; string consumerGroup = 4; @@ -82,17 +100,17 @@ message Heartbeat { } service PublisherService { - rpc publish(Message) returns (Response); + rpc publish(EventMeshMessage) returns (Response); - rpc requestReply(Message) returns (Response); + rpc requestReply(EventMeshMessage) returns (Response); - rpc broadcast(Message) returns (Response); + rpc broadcast(EventMeshMessage) returns (Response); } service ConsumerService { rpc subscribe(Subscription) returns (Response); - rpc subscribeStream(Subscription) returns (stream Message); + rpc subscribeStream(Subscription) returns (stream EventMeshMessage); rpc unsubscribe(Subscription) returns (Response); } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/build.gradle b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/build.gradle new file mode 100644 index 0000000000..9ea07e10f6 --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/build.gradle @@ -0,0 +1,26 @@ +/* + * Licensed 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. + */ + +dependencies { + implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api") + implementation "io.cloudevents:cloudevents-core" + implementation "io.grpc:grpc-protobuf:1.15.0" + + testImplementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api") + testImplementation "io.cloudevents:cloudevents-core" + testImplementation "junit:junit" +} diff --git a/eventmesh-registry-plugin/eventmesh-registry-namesrv/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.registry.RegistryService b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/gradle.properties similarity index 91% rename from eventmesh-registry-plugin/eventmesh-registry-namesrv/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.registry.RegistryService rename to eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/gradle.properties index 5e75096b5f..07476be28a 100644 --- a/eventmesh-registry-plugin/eventmesh-registry-namesrv/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.registry.RegistryService +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/gradle.properties @@ -12,5 +12,7 @@ # 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. +# -namesrv=org.apache.eventmesh.registry.namesrv.RegistryServiceNamesrvImpl \ No newline at end of file +pluginType=protocol +pluginName=eventmeshmessage \ No newline at end of file diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java new file mode 100644 index 0000000000..70bcb03a06 --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java @@ -0,0 +1,133 @@ +/* + * Licensed 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.eventmesh.protocol.meshmessage; + +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; +import org.apache.eventmesh.common.protocol.http.HttpCommand; +import org.apache.eventmesh.common.protocol.http.body.Body; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; +import org.apache.eventmesh.common.protocol.tcp.Header; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; +import org.apache.eventmesh.protocol.meshmessage.resolver.grpc.GrpcMessageProtocolResolver; +import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageBatchProtocolResolver; +import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageBatchV2ProtocolResolver; +import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageRequestProtocolResolver; +import org.apache.eventmesh.protocol.meshmessage.resolver.tcp.TcpMessageProtocolResolver; + +import org.apache.commons.lang3.StringUtils; + +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import io.cloudevents.CloudEvent; + +public class MeshMessageProtocolAdaptor implements ProtocolAdaptor { + + @Override + public CloudEvent toCloudEvent(ProtocolTransportObject protocol) throws ProtocolHandleException { + if (protocol instanceof Package) { + Package tcpPackage = (Package) protocol; + Header header = tcpPackage.getHeader(); + String bodyJson = (String) tcpPackage.getBody(); + + return deserializeTcpProtocol(header, bodyJson); + + } else if (protocol instanceof HttpCommand) { + org.apache.eventmesh.common.protocol.http.header.Header header = ((HttpCommand) protocol).getHeader(); + Body body = ((HttpCommand) protocol).getBody(); + String requestCode = ((HttpCommand) protocol).getRequestCode(); + + return deserializeHttpProtocol(requestCode, header, body); + } else if (protocol instanceof EventMeshMessageWrapper) { + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage message = ((EventMeshMessageWrapper)protocol).getMessage(); + return deserializeGrpcProtocol(message); + } else { + throw new ProtocolHandleException(String.format("protocol class: %s", protocol.getClass())); + } + } + + private CloudEvent deserializeGrpcProtocol(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage message) + throws ProtocolHandleException { + return GrpcMessageProtocolResolver.buildEvent(message); + } + + private CloudEvent deserializeTcpProtocol(Header header, String bodyJson) throws ProtocolHandleException { + return TcpMessageProtocolResolver.buildEvent(header, JsonUtils.deserialize(bodyJson, EventMeshMessage.class)); + } + + private CloudEvent deserializeHttpProtocol(String requestCode, + org.apache.eventmesh.common.protocol.http.header.Header header, + Body body) throws ProtocolHandleException { + + if (String.valueOf(RequestCode.MSG_BATCH_SEND.getRequestCode()).equals(requestCode)) { + return SendMessageBatchProtocolResolver.buildEvent(header, body); + } else if (String.valueOf(RequestCode.MSG_BATCH_SEND_V2.getRequestCode()).equals(requestCode)) { + return SendMessageBatchV2ProtocolResolver.buildEvent(header, body); + } else if (String.valueOf(RequestCode.MSG_SEND_SYNC.getRequestCode()).equals(requestCode)) { + return SendMessageRequestProtocolResolver.buildEvent(header, body); + } else if (String.valueOf(RequestCode.MSG_SEND_ASYNC.getRequestCode()).equals(requestCode)) { + return SendMessageRequestProtocolResolver.buildEvent(header, body); + } else { + throw new ProtocolHandleException(String.format("unsupported requestCode: %s", requestCode)); + } + + } + + @Override + public List toBatchCloudEvent(ProtocolTransportObject protocol) throws ProtocolHandleException { + return null; + } + + @Override + public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleException { + String protocolDesc = cloudEvent.getExtension(Constants.PROTOCOL_DESC).toString(); + + // both http and grpc consumers are using HTTP webhook to send send message to target URL + if (StringUtils.equals("http", protocolDesc) || StringUtils.equals("grpc", protocolDesc)) { + HttpCommand httpCommand = new HttpCommand(); + Body body = new Body() { + final Map map = new HashMap<>(); + @Override + public Map toMap() { + map.put("content", new String(cloudEvent.getData().toBytes(), StandardCharsets.UTF_8)); + return map; + } + }; + body.toMap(); + httpCommand.setBody(body); + return httpCommand; + } else if (StringUtils.equals("tcp", protocolDesc)) { + return TcpMessageProtocolResolver.buildEventMeshMessage(cloudEvent); + } else { + throw new ProtocolHandleException(String.format("Unsupported protocolDesc: %s", protocolDesc)); + } + } + + @Override + public String getProtocolType() { + return MeshMessageProtocolConstant.PROTOCOL_NAME; + } +} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/request/SchemaCreateRequest.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolConstant.java similarity index 82% rename from eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/request/SchemaCreateRequest.java rename to eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolConstant.java index 0a052c9db9..0a667f63f0 100644 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/request/SchemaCreateRequest.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolConstant.java @@ -14,12 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.eventmesh.schema.registry.server.request; -import lombok.AllArgsConstructor; -import lombok.Data; +package org.apache.eventmesh.protocol.meshmessage; -@Data -@AllArgsConstructor -public class SchemaCreateRequest { +public enum MeshMessageProtocolConstant { + ; + public static final String PROTOCOL_NAME = "eventmeshmessage"; } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java new file mode 100644 index 0000000000..f7fccb1680 --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java @@ -0,0 +1,97 @@ +package org.apache.eventmesh.protocol.meshmessage.resolver.grpc; + +import io.cloudevents.CloudEvent; +import io.cloudevents.SpecVersion; +import io.cloudevents.core.builder.CloudEventBuilder; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.protocol.grpc.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; + +import java.net.URI; +import java.nio.charset.StandardCharsets; + +public class GrpcMessageProtocolResolver { + + public static CloudEvent buildEvent(EventMeshMessage message) throws ProtocolHandleException { + try { + RequestHeader requestHeader = message.getHeader(); + + String protocolType = requestHeader.getProtocolType(); + String protocolDesc = requestHeader.getProtocolDesc(); + String protocolVersion = requestHeader.getProtocolVersion(); + + String env = requestHeader.getEnv(); + String idc = requestHeader.getIdc(); + String ip = requestHeader.getIp(); + String pid = requestHeader.getPid(); + String sys = requestHeader.getSys(); + String username = requestHeader.getUsername(); + String passwd = requestHeader.getPassword(); + String language = requestHeader.getLanguage(); + + String content = message.getContent(); + + CloudEvent event = null; + CloudEventBuilder cloudEventBuilder; + if (StringUtils.equals(SpecVersion.V1.toString(), protocolVersion)) { + cloudEventBuilder = CloudEventBuilder.v1(); + + cloudEventBuilder = cloudEventBuilder.withId(message.getSeqNum()) + .withSubject(message.getTopic()) + .withType("eventmeshmessage") + .withSource(URI.create("/")) + .withData(content.getBytes(StandardCharsets.UTF_8)) + .withExtension(ProtocolKey.ENV, env) + .withExtension(ProtocolKey.IDC, idc) + .withExtension(ProtocolKey.IP, ip) + .withExtension(ProtocolKey.PID, pid) + .withExtension(ProtocolKey.SYS, sys) + .withExtension(ProtocolKey.USERNAME, username) + .withExtension(ProtocolKey.PASSWD, passwd) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(ProtocolKey.SEQ_NUM, message.getSeqNum()) + .withExtension(ProtocolKey.UNIQUE_ID, message.getUniqueId()) + .withExtension(ProtocolKey.PRODUCERGROUP, message.getProducerGroup()) + .withExtension(ProtocolKey.TTL, message.getTtl()); + if (StringUtils.isNotEmpty(message.getTag())) { + cloudEventBuilder = cloudEventBuilder.withExtension(ProtocolKey.TAG, message.getTag()); + } + event = cloudEventBuilder.build(); + } else if (StringUtils.equals(SpecVersion.V03.toString(), protocolVersion)) { + cloudEventBuilder = CloudEventBuilder.v03(); + cloudEventBuilder = cloudEventBuilder.withId(message.getSeqNum()) + .withSubject(message.getTopic()) + .withType("eventmeshmessage") + .withSource(URI.create("/")) + .withData(content.getBytes(StandardCharsets.UTF_8)) + .withExtension(ProtocolKey.ENV, env) + .withExtension(ProtocolKey.IDC, idc) + .withExtension(ProtocolKey.IP, ip) + .withExtension(ProtocolKey.PID, pid) + .withExtension(ProtocolKey.SYS, sys) + .withExtension(ProtocolKey.USERNAME, username) + .withExtension(ProtocolKey.PASSWD, passwd) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(ProtocolKey.SEQ_NUM, message.getSeqNum()) + .withExtension(ProtocolKey.UNIQUE_ID, message.getUniqueId()) + .withExtension(ProtocolKey.PRODUCERGROUP, message.getProducerGroup()) + .withExtension(ProtocolKey.TTL, message.getTtl()); + if (StringUtils.isNotEmpty(message.getTag())) { + cloudEventBuilder = cloudEventBuilder.withExtension(ProtocolKey.TAG, message.getTag()); + } + event = cloudEventBuilder.build(); + } + return event; + } catch (Exception e) { + throw new ProtocolHandleException(e.getMessage(), e.getCause()); + } + } +} diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageBatchProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageBatchProtocolResolver.java new file mode 100644 index 0000000000..cd8f8179e7 --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageBatchProtocolResolver.java @@ -0,0 +1,28 @@ +/* + * Licensed 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.eventmesh.protocol.meshmessage.resolver.http; + +import io.cloudevents.CloudEvent; +import org.apache.eventmesh.common.protocol.http.body.Body; +import org.apache.eventmesh.common.protocol.http.header.Header; + +public class SendMessageBatchProtocolResolver { + public static CloudEvent buildEvent(Header header, Body body) { + return null; + } +} diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageBatchV2ProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageBatchV2ProtocolResolver.java new file mode 100644 index 0000000000..0f3678fae7 --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageBatchV2ProtocolResolver.java @@ -0,0 +1,122 @@ +/* + * Licensed 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.eventmesh.protocol.meshmessage.resolver.http; + +import io.cloudevents.CloudEvent; +import io.cloudevents.SpecVersion; +import io.cloudevents.core.builder.CloudEventBuilder; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.protocol.http.body.Body; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchV2RequestBody; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; +import org.apache.eventmesh.common.protocol.http.header.Header; +import org.apache.eventmesh.common.protocol.http.header.message.SendMessageBatchV2RequestHeader; +import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; + +import java.net.URI; +import java.nio.charset.StandardCharsets; + +public class SendMessageBatchV2ProtocolResolver { + public static CloudEvent buildEvent(Header header, Body body) throws ProtocolHandleException { + try { + SendMessageBatchV2RequestHeader sendMessageBatchV2RequestHeader = (SendMessageBatchV2RequestHeader) header; + SendMessageBatchV2RequestBody sendMessageBatchV2RequestBody = (SendMessageBatchV2RequestBody) body; + + String protocolType = sendMessageBatchV2RequestHeader.getProtocolType(); + String protocolDesc = sendMessageBatchV2RequestHeader.getProtocolDesc(); + String protocolVersion = sendMessageBatchV2RequestHeader.getProtocolVersion(); + + String code = sendMessageBatchV2RequestHeader.getCode(); + String env = sendMessageBatchV2RequestHeader.getEnv(); + String idc = sendMessageBatchV2RequestHeader.getIdc(); + String ip = sendMessageBatchV2RequestHeader.getIp(); + String pid = sendMessageBatchV2RequestHeader.getPid(); + String sys = sendMessageBatchV2RequestHeader.getSys(); + String username = sendMessageBatchV2RequestHeader.getUsername(); + String passwd = sendMessageBatchV2RequestHeader.getPasswd(); + ProtocolVersion version = sendMessageBatchV2RequestHeader.getVersion(); + String language = sendMessageBatchV2RequestHeader.getLanguage(); + + String content = sendMessageBatchV2RequestBody.getMsg(); + + CloudEvent event = null; + CloudEventBuilder cloudEventBuilder; + if (StringUtils.equals(SpecVersion.V1.toString(), protocolVersion)) { + cloudEventBuilder = CloudEventBuilder.v1(); + + cloudEventBuilder = cloudEventBuilder.withId(sendMessageBatchV2RequestBody.getBizSeqNo()) + .withSubject(sendMessageBatchV2RequestBody.getTopic()) + .withType("eventmeshmessage") + .withSource(URI.create("/")) + .withData(content.getBytes(StandardCharsets.UTF_8)) + .withExtension(ProtocolKey.REQUEST_CODE, code) + .withExtension(ProtocolKey.ClientInstanceKey.ENV, env) + .withExtension(ProtocolKey.ClientInstanceKey.IDC, idc) + .withExtension(ProtocolKey.ClientInstanceKey.IP, ip) + .withExtension(ProtocolKey.ClientInstanceKey.PID, pid) + .withExtension(ProtocolKey.ClientInstanceKey.SYS, sys) + .withExtension(ProtocolKey.ClientInstanceKey.USERNAME, username) + .withExtension(ProtocolKey.ClientInstanceKey.PASSWD, passwd) + .withExtension(ProtocolKey.VERSION, version.getVersion()) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(SendMessageBatchV2RequestBody.BIZSEQNO, sendMessageBatchV2RequestBody.getBizSeqNo()) + .withExtension(SendMessageBatchV2RequestBody.PRODUCERGROUP, sendMessageBatchV2RequestBody.getProducerGroup()) + .withExtension(SendMessageBatchV2RequestBody.TTL, sendMessageBatchV2RequestBody.getTtl()); + if (StringUtils.isNotEmpty(sendMessageBatchV2RequestBody.getTag())) { + cloudEventBuilder = cloudEventBuilder.withExtension(SendMessageRequestBody.TAG, sendMessageBatchV2RequestBody.getTag()); + } + event = cloudEventBuilder.build(); + } else if (StringUtils.equals(SpecVersion.V03.toString(), protocolVersion)) { + cloudEventBuilder = CloudEventBuilder.v03(); + cloudEventBuilder = cloudEventBuilder.withId(sendMessageBatchV2RequestBody.getBizSeqNo()) + .withSubject(sendMessageBatchV2RequestBody.getTopic()) + .withType("eventmeshmessage") + .withSource(URI.create("/")) + .withData(content.getBytes(StandardCharsets.UTF_8)) + .withExtension(ProtocolKey.REQUEST_CODE, code) + .withExtension(ProtocolKey.ClientInstanceKey.ENV, env) + .withExtension(ProtocolKey.ClientInstanceKey.IDC, idc) + .withExtension(ProtocolKey.ClientInstanceKey.IP, ip) + .withExtension(ProtocolKey.ClientInstanceKey.PID, pid) + .withExtension(ProtocolKey.ClientInstanceKey.SYS, sys) + .withExtension(ProtocolKey.ClientInstanceKey.USERNAME, username) + .withExtension(ProtocolKey.ClientInstanceKey.PASSWD, passwd) + .withExtension(ProtocolKey.VERSION, version.getVersion()) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(SendMessageBatchV2RequestBody.BIZSEQNO, sendMessageBatchV2RequestBody.getBizSeqNo()) + .withExtension(SendMessageBatchV2RequestBody.PRODUCERGROUP, sendMessageBatchV2RequestBody.getProducerGroup()) + .withExtension(SendMessageBatchV2RequestBody.TTL, sendMessageBatchV2RequestBody.getTtl()); + if (StringUtils.isNotEmpty(sendMessageBatchV2RequestBody.getTag())) { + cloudEventBuilder = cloudEventBuilder.withExtension(SendMessageRequestBody.TAG, sendMessageBatchV2RequestBody.getTag()); + } + event = cloudEventBuilder.build(); + } + return event; + } catch (Exception e) { + throw new ProtocolHandleException(e.getMessage(), e.getCause()); + } + } +} diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageRequestProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageRequestProtocolResolver.java new file mode 100644 index 0000000000..ace5bfeadd --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/http/SendMessageRequestProtocolResolver.java @@ -0,0 +1,129 @@ +/* + * Licensed 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.eventmesh.protocol.meshmessage.resolver.http; + +import org.apache.eventmesh.common.protocol.http.body.Body; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchV2RequestBody; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; +import org.apache.eventmesh.common.protocol.http.header.Header; +import org.apache.eventmesh.common.protocol.http.header.message.SendMessageRequestHeader; +import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; + +import org.apache.commons.lang3.StringUtils; + +import java.net.URI; +import java.nio.charset.StandardCharsets; + +import io.cloudevents.CloudEvent; +import io.cloudevents.SpecVersion; +import io.cloudevents.core.builder.CloudEventBuilder; + +public class SendMessageRequestProtocolResolver { + + public static CloudEvent buildEvent(Header header, Body body) throws ProtocolHandleException { + try { + SendMessageRequestHeader sendMessageRequestHeader = (SendMessageRequestHeader) header; + SendMessageRequestBody sendMessageRequestBody = (SendMessageRequestBody) body; + + String protocolType = sendMessageRequestHeader.getProtocolType(); + String protocolDesc = sendMessageRequestHeader.getProtocolDesc(); + String protocolVersion = sendMessageRequestHeader.getProtocolVersion(); + + String code = sendMessageRequestHeader.getCode(); + String env = sendMessageRequestHeader.getEnv(); + String idc = sendMessageRequestHeader.getIdc(); + String ip = sendMessageRequestHeader.getIp(); + String pid = sendMessageRequestHeader.getPid(); + String sys = sendMessageRequestHeader.getSys(); + String username = sendMessageRequestHeader.getUsername(); + String passwd = sendMessageRequestHeader.getPasswd(); + ProtocolVersion version = sendMessageRequestHeader.getVersion(); + String language = sendMessageRequestHeader.getLanguage(); + + String content = sendMessageRequestBody.getContent(); + + CloudEvent event = null; + CloudEventBuilder cloudEventBuilder; + if (StringUtils.equals(SpecVersion.V1.toString(), protocolVersion)) { + cloudEventBuilder = CloudEventBuilder.v1(); + + cloudEventBuilder = cloudEventBuilder.withId(sendMessageRequestBody.getBizSeqNo()) + .withSubject(sendMessageRequestBody.getTopic()) + .withType("eventmeshmessage") + .withSource(URI.create("/")) + .withData(content.getBytes(StandardCharsets.UTF_8)) + .withExtension(ProtocolKey.REQUEST_CODE, code) + .withExtension(ProtocolKey.ClientInstanceKey.ENV, env) + .withExtension(ProtocolKey.ClientInstanceKey.IDC, idc) + .withExtension(ProtocolKey.ClientInstanceKey.IP, ip) + .withExtension(ProtocolKey.ClientInstanceKey.PID, pid) + .withExtension(ProtocolKey.ClientInstanceKey.SYS, sys) + .withExtension(ProtocolKey.ClientInstanceKey.USERNAME, username) + .withExtension(ProtocolKey.ClientInstanceKey.PASSWD, passwd) + .withExtension(ProtocolKey.VERSION, version.getVersion()) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(SendMessageRequestBody.BIZSEQNO, sendMessageRequestBody.getBizSeqNo()) + .withExtension(SendMessageRequestBody.UNIQUEID, sendMessageRequestBody.getUniqueId()) + .withExtension(SendMessageRequestBody.PRODUCERGROUP, + sendMessageRequestBody.getProducerGroup()) + .withExtension(SendMessageRequestBody.TTL, sendMessageRequestBody.getTtl()); + if (StringUtils.isNotEmpty(sendMessageRequestBody.getTag())) { + cloudEventBuilder = cloudEventBuilder.withExtension(SendMessageRequestBody.TAG, sendMessageRequestBody.getTag()); + } + event = cloudEventBuilder.build(); + } else if (StringUtils.equals(SpecVersion.V03.toString(), protocolVersion)) { + cloudEventBuilder = CloudEventBuilder.v03(); + cloudEventBuilder = cloudEventBuilder.withId(sendMessageRequestBody.getBizSeqNo()) + .withSubject(sendMessageRequestBody.getTopic()) + .withType("eventmeshmessage") + .withSource(URI.create("/")) + .withData(content.getBytes(StandardCharsets.UTF_8)) + .withExtension(ProtocolKey.REQUEST_CODE, code) + .withExtension(ProtocolKey.ClientInstanceKey.ENV, env) + .withExtension(ProtocolKey.ClientInstanceKey.IDC, idc) + .withExtension(ProtocolKey.ClientInstanceKey.IP, ip) + .withExtension(ProtocolKey.ClientInstanceKey.PID, pid) + .withExtension(ProtocolKey.ClientInstanceKey.SYS, sys) + .withExtension(ProtocolKey.ClientInstanceKey.USERNAME, username) + .withExtension(ProtocolKey.ClientInstanceKey.PASSWD, passwd) + .withExtension(ProtocolKey.VERSION, version.getVersion()) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(SendMessageRequestBody.BIZSEQNO, sendMessageRequestBody.getBizSeqNo()) + .withExtension(SendMessageRequestBody.UNIQUEID, sendMessageRequestBody.getUniqueId()) + .withExtension(SendMessageRequestBody.PRODUCERGROUP, + sendMessageRequestBody.getProducerGroup()) + .withExtension(SendMessageRequestBody.TTL, sendMessageRequestBody.getTtl()); + if (StringUtils.isNotEmpty(sendMessageRequestBody.getTag())) { + cloudEventBuilder = cloudEventBuilder.withExtension(SendMessageRequestBody.TAG, sendMessageRequestBody.getTag()); + } + event = cloudEventBuilder.build(); + } + return event; + } catch (Exception e) { + throw new ProtocolHandleException(e.getMessage(), e.getCause()); + } + } +} diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/tcp/TcpMessageProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/tcp/TcpMessageProtocolResolver.java new file mode 100644 index 0000000000..e0d2f4e789 --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/tcp/TcpMessageProtocolResolver.java @@ -0,0 +1,107 @@ +/* + * Licensed 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.eventmesh.protocol.meshmessage.resolver.tcp; + +import io.cloudevents.CloudEvent; +import io.cloudevents.SpecVersion; +import io.cloudevents.core.builder.CloudEventBuilder; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; +import org.apache.eventmesh.common.protocol.tcp.Header; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; +import org.apache.eventmesh.protocol.meshmessage.MeshMessageProtocolConstant; + +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + +public class TcpMessageProtocolResolver { + + + public static CloudEvent buildEvent(Header header, EventMeshMessage message) throws ProtocolHandleException { + + CloudEventBuilder cloudEventBuilder; + + String protocolType = header.getProperty(Constants.PROTOCOL_TYPE).toString(); + String protocolVersion = header.getProperty(Constants.PROTOCOL_VERSION).toString(); + String protocolDesc = header.getProperty(Constants.PROTOCOL_DESC).toString(); + + if (StringUtils.isBlank(protocolType) + || StringUtils.isBlank(protocolVersion) + || StringUtils.isBlank(protocolDesc)) { + throw new ProtocolHandleException(String.format("invalid protocol params protocolType %s|protocolVersion %s|protocolDesc %s", + protocolType, protocolVersion, protocolDesc)); + } + + if (!StringUtils.equals(MeshMessageProtocolConstant.PROTOCOL_NAME, protocolType)) { + throw new ProtocolHandleException(String.format("Unsupported protocolType: %s", protocolType)); + } + + String topic = message.getTopic(); + + String content = message.getBody(); + + if (StringUtils.equals(SpecVersion.V1.toString(), protocolVersion)) { + cloudEventBuilder = CloudEventBuilder.v1(); + + } else if (StringUtils.equals(SpecVersion.V03.toString(), protocolVersion)) { + cloudEventBuilder = CloudEventBuilder.v03(); + + } else { + throw new ProtocolHandleException(String.format("Unsupported protocolVersion: %s", protocolVersion)); + } + + cloudEventBuilder = cloudEventBuilder + .withId(header.getSeq()) + .withSource(URI.create("/")) + .withType("eventmeshmessage") + .withSubject(topic) + .withData(content.getBytes(StandardCharsets.UTF_8)); + + for (String propKey : header.getProperties().keySet()) { + cloudEventBuilder.withExtension(propKey, header.getProperty(propKey).toString()); + } + + for (String propKey : message.getProperties().keySet()) { + cloudEventBuilder.withExtension(propKey, message.getProperties().get(propKey)); + } + + return cloudEventBuilder.build(); + + } + + public static Package buildEventMeshMessage(CloudEvent cloudEvent) { + EventMeshMessage eventMeshMessage = new EventMeshMessage(); + eventMeshMessage.setTopic(cloudEvent.getSubject()); + eventMeshMessage.setBody(new String(cloudEvent.getData().toBytes(), StandardCharsets.UTF_8)); + + Map prop = new HashMap<>(); + for (String extKey : cloudEvent.getExtensionNames()) { + prop.put(extKey, cloudEvent.getExtension(extKey).toString()); + } + eventMeshMessage.setProperties(prop); + + Package pkg = new Package(); + pkg.setBody(eventMeshMessage); + + return pkg; + } +} diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor new file mode 100644 index 0000000000..45ffc15eac --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.protocol.api.ProtocolAdaptor @@ -0,0 +1,16 @@ +# Licensed 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. + +eventmeshmessage=org.apache.eventmesh.protocol.meshmessage.MeshMessageProtocolAdaptor \ No newline at end of file diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/test/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptorTest.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/test/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptorTest.java new file mode 100644 index 0000000000..54108bf79f --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/test/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptorTest.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.eventmesh.protocol.meshmessage; + +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; + +import org.junit.Assert; +import org.junit.Test; + +public class MeshMessageProtocolAdaptorTest { + + @Test + public void loadPlugin() { + ProtocolAdaptor protocolAdaptor = + ProtocolPluginFactory.getProtocolAdaptor(MeshMessageProtocolConstant.PROTOCOL_NAME); + Assert.assertNotNull(protocolAdaptor); + + Assert.assertEquals( + MeshMessageProtocolConstant.PROTOCOL_NAME, protocolAdaptor.getProtocolType() + ); + } + + @Test + public void getProtocolType() { + } +} \ No newline at end of file diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/build.gradle b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/build.gradle index 27c8997a1d..86065d7342 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/build.gradle +++ b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/build.gradle @@ -16,7 +16,7 @@ */ dependencies { - compileOnly project(":eventmesh-protocol-plugin:eventmesh-protocol-api") + implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api") implementation "io.cloudevents:cloudevents-core" implementation "io.openmessaging:openmessaging-api" diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptor.java b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptor.java index cea3d793ea..00a48b19a8 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptor.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/main/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptor.java @@ -17,11 +17,14 @@ package org.apache.eventmesh.protocol.openmessage; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; import org.apache.eventmesh.protocol.api.ProtocolAdaptor; import io.cloudevents.CloudEvent; -import io.cloudevents.core.v1.CloudEventV1; import io.openmessaging.api.Message; +import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; + +import java.util.List; /** * OpenMessage protocol adaptor, used to transform protocol between @@ -29,15 +32,20 @@ * * @since 1.3.0 */ -public class OpenMessageProtocolAdaptor implements ProtocolAdaptor { +public class OpenMessageProtocolAdaptor implements ProtocolAdaptor { + + @Override + public CloudEvent toCloudEvent(ProtocolTransportObject message) { + return null; + } @Override - public CloudEventV1 toCloudEventV1(Package message) { + public List toBatchCloudEvent(ProtocolTransportObject protocol) throws ProtocolHandleException { return null; } @Override - public Package fromCloudEventV1(CloudEventV1 cloudEvent) { + public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) { return null; } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/test/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptorTest.java b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/test/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptorTest.java index 60c2eb6613..5d833ec580 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/test/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptorTest.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-openmessage/src/test/java/org/apache/eventmesh/protocol/openmessage/OpenMessageProtocolAdaptorTest.java @@ -17,6 +17,7 @@ package org.apache.eventmesh.protocol.openmessage; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; import org.apache.eventmesh.protocol.api.ProtocolAdaptor; import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; @@ -27,7 +28,7 @@ public class OpenMessageProtocolAdaptorTest { @Test public void loadPlugin() { - ProtocolAdaptor protocolAdaptor = + ProtocolAdaptor protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(OpenMessageProtocolConstant.PROTOCOL_NAME); Assert.assertNotNull(protocolAdaptor); diff --git a/eventmesh-registry-plugin/eventmesh-registry-api/build.gradle b/eventmesh-registry-plugin/eventmesh-registry-api/build.gradle index 594503e74f..0d410425ba 100644 --- a/eventmesh-registry-plugin/eventmesh-registry-api/build.gradle +++ b/eventmesh-registry-plugin/eventmesh-registry-api/build.gradle @@ -16,7 +16,7 @@ */ dependencies { - implementation project(":eventmesh-spi") + api project(":eventmesh-spi") testImplementation project(":eventmesh-spi") } diff --git a/eventmesh-registry-plugin/eventmesh-registry-namesrv/src/main/java/org/apache/eventmesh/registry/namesrv/RegistryServiceNamesrvImpl.java b/eventmesh-registry-plugin/eventmesh-registry-namesrv/src/main/java/org/apache/eventmesh/registry/namesrv/RegistryServiceNamesrvImpl.java deleted file mode 100644 index 7b11b515e8..0000000000 --- a/eventmesh-registry-plugin/eventmesh-registry-namesrv/src/main/java/org/apache/eventmesh/registry/namesrv/RegistryServiceNamesrvImpl.java +++ /dev/null @@ -1,63 +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 org.apache.eventmesh.registry.namesrv; - -import org.apache.eventmesh.api.exception.RegistryException; -import org.apache.eventmesh.api.registry.RegistryService; -import org.apache.eventmesh.api.registry.dto.EventMeshDataInfo; -import org.apache.eventmesh.api.registry.dto.EventMeshRegisterInfo; -import org.apache.eventmesh.api.registry.dto.EventMeshUnRegisterInfo; - -import java.util.List; -import java.util.Map; - -public class RegistryServiceNamesrvImpl implements RegistryService { - @Override - public void init() throws RegistryException { - - } - - @Override - public void start() throws RegistryException { - - } - - @Override - public void shutdown() throws RegistryException { - - } - - @Override - public List findEventMeshInfoByCluster(String clusterName) throws RegistryException { - return null; - } - - @Override - public Map> findEventMeshClientDistributionData(String clusterName, String group, String purpose) throws RegistryException { - return null; - } - - @Override - public boolean register(EventMeshRegisterInfo eventMeshRegisterInfo) throws RegistryException { - return true; - } - - @Override - public boolean unRegister(EventMeshUnRegisterInfo eventMeshUnRegisterInfo) throws RegistryException { - return true; - } -} diff --git a/eventmesh-runtime/bin/start.sh b/eventmesh-runtime/bin/start.sh index c2cb39915a..737f3d87b4 100644 --- a/eventmesh-runtime/bin/start.sh +++ b/eventmesh-runtime/bin/start.sh @@ -134,6 +134,7 @@ JAVA_OPT="${JAVA_OPT} -Deventmesh.log.home=${EVENTMESH_LOG_HOME}" JAVA_OPT="${JAVA_OPT} -DconfPath=${EVENTMESH_HOME}/conf" JAVA_OPT="${JAVA_OPT} -Dlog4j2.AsyncQueueFullPolicy=Discard" JAVA_OPT="${JAVA_OPT} -Drocketmq.client.logUseSlf4j=true" +JAVA_OPT="${JAVA_OPT} -DeventMeshPluginDir=${EVENTMESH_HOME}/plugin" #if [ -f "pid.file" ]; then # pid=`cat pid.file` diff --git a/eventmesh-runtime/build.gradle b/eventmesh-runtime/build.gradle index ebf498049f..980c3cd2fc 100644 --- a/eventmesh-runtime/build.gradle +++ b/eventmesh-runtime/build.gradle @@ -15,6 +15,8 @@ * limitations under the License. */ +def grpcVersion = '1.15.0' + dependencies { implementation 'io.opentelemetry:opentelemetry-api' implementation 'io.opentelemetry:opentelemetry-sdk' @@ -23,6 +25,9 @@ dependencies { implementation 'io.prometheus:simpleclient' implementation 'io.prometheus:simpleclient_httpserver' implementation 'io.cloudevents:cloudevents-core' + implementation 'io.opentelemetry:opentelemetry-exporter-zipkin' + implementation 'io.opentelemetry:opentelemetry-semconv' + implementation "org.apache.httpcomponents:httpclient" implementation 'io.netty:netty-all' @@ -34,10 +39,23 @@ dependencies { implementation project(":eventmesh-security-plugin:eventmesh-security-api") implementation project(":eventmesh-security-plugin:eventmesh-security-acl") implementation project(":eventmesh-registry-plugin:eventmesh-registry-api") - implementation project(":eventmesh-registry-plugin:eventmesh-registry-namesrv") + implementation project(":eventmesh-admin:eventmesh-admin-rocketmq") implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api") + implementation "io.grpc:grpc-protobuf:${grpcVersion}" + implementation "io.grpc:grpc-stub:${grpcVersion}" + implementation "io.grpc:grpc-netty:${grpcVersion}" + implementation "io.grpc:grpc-netty-shaded:${grpcVersion}" + + compileOnly 'org.projectlombok:lombok:1.18.22' + annotationProcessor 'org.projectlombok:lombok:1.18.22' + + // for debug only, can be removed + implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-cloudevents") + implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-meshmessage") + implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-openmessage") + testImplementation project(":eventmesh-common") testImplementation project(":eventmesh-spi") testImplementation project(":eventmesh-connector-plugin:eventmesh-connector-api") @@ -45,7 +63,7 @@ dependencies { testImplementation project(":eventmesh-security-plugin:eventmesh-security-api") testImplementation project(":eventmesh-security-plugin:eventmesh-security-acl") testImplementation project(":eventmesh-registry-plugin:eventmesh-registry-api") - testImplementation project(":eventmesh-registry-plugin:eventmesh-registry-namesrv") + testImplementation project(":eventmesh-admin:eventmesh-admin-rocketmq") testImplementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api") diff --git a/eventmesh-runtime/conf/eventmesh.properties b/eventmesh-runtime/conf/eventmesh.properties index 30cdf4dccf..61fcb3b388 100644 --- a/eventmesh-runtime/conf/eventmesh.properties +++ b/eventmesh-runtime/conf/eventmesh.properties @@ -21,6 +21,7 @@ eventMesh.server.cluster=COMMON eventMesh.server.name=EVENTMESH-runtime eventMesh.sysid=0000 eventMesh.server.http.port=10105 +eventMesh.server.grpc.port=10205 ########################## eventMesh tcp configuration ############################ eventMesh.server.tcp.enabled=true eventMesh.server.tcp.port=10000 @@ -72,4 +73,20 @@ eventMesh.server.registry.enabled=false eventMesh.registry.plugin.type=namesrv #prometheusPort -eventMesh.metrics.prometheus.port=19090 \ No newline at end of file +eventMesh.metrics.prometheus.port=19090 + +#trace exporter +eventmesh.trace.exporter.type=Zipkin + +#set the maximum batch size to use +eventmesh.trace.exporter.max.export.size=512 +#set the queue size. This must be >= the export batch size +eventmesh.trace.exporter.max.queue.size=2048 +#set the max amount of time an export can run before getting(TimeUnit=SECONDS) +eventmesh.trace.exporter.export.timeout=30 +#set time between two different exports(TimeUnit=SECONDS) +eventmesh.trace.exporter.export.interval=5 + +#zipkin +eventmesh.trace.export.zipkin.ip=localhost +eventmesh.trace.export.zipkin.port=9411 \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java index cb773f4eb4..bf762ebd92 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/acl/Acl.java @@ -20,7 +20,7 @@ import org.apache.eventmesh.api.acl.AclPropertyKeys; import org.apache.eventmesh.api.acl.AclService; import org.apache.eventmesh.api.exception.AclException; -import org.apache.eventmesh.api.producer.MeshMQProducer; +//import org.apache.eventmesh.api.producer.MeshMQProducer; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.spi.EventMeshExtensionFactory; import org.slf4j.Logger; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/ClientManageController.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/ClientManageController.java index cd6d094db5..3fc2e8e2b8 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/ClientManageController.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/ClientManageController.java @@ -17,21 +17,34 @@ package org.apache.eventmesh.runtime.admin.controller; +import org.apache.eventmesh.admin.rocketmq.controller.AdminController; +import org.apache.eventmesh.runtime.admin.handler.QueryRecommendEventMeshHandler; +import org.apache.eventmesh.runtime.admin.handler.RedirectClientByIpPortHandler; +import org.apache.eventmesh.runtime.admin.handler.RedirectClientByPathHandler; +import org.apache.eventmesh.runtime.admin.handler.RedirectClientBySubSystemHandler; +import org.apache.eventmesh.runtime.admin.handler.RejectAllClientHandler; +import org.apache.eventmesh.runtime.admin.handler.RejectClientByIpPortHandler; +import org.apache.eventmesh.runtime.admin.handler.RejectClientBySubSystemHandler; +import org.apache.eventmesh.runtime.admin.handler.ShowClientBySystemHandler; +import org.apache.eventmesh.runtime.admin.handler.ShowClientHandler; +import org.apache.eventmesh.runtime.admin.handler.ShowListenClientByTopicHandler; +import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; + import java.io.IOException; import java.net.InetSocketAddress; -import com.sun.net.httpserver.HttpServer; - -import org.apache.eventmesh.runtime.admin.handler.*; -import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.sun.net.httpserver.HttpServer; + public class ClientManageController { private static final Logger logger = LoggerFactory.getLogger(ClientManageController.class); private EventMeshTCPServer eventMeshTCPServer; + + private AdminController adminController; public ClientManageController(EventMeshTCPServer eventMeshTCPServer) { this.eventMeshTCPServer = eventMeshTCPServer; @@ -50,6 +63,10 @@ public void start() throws IOException { server.createContext("/clientManage/redirectClientByIpPort", new RedirectClientByIpPortHandler(eventMeshTCPServer)); server.createContext("/clientManage/showListenClientByTopic", new ShowListenClientByTopicHandler(eventMeshTCPServer)); server.createContext("/eventMesh/recommend", new QueryRecommendEventMeshHandler(eventMeshTCPServer)); + + adminController = new AdminController(); + adminController.run(server); + server.start(); logger.info("ClientManageController start success, port:{}", port); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectAllClientHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectAllClientHandler.java index 6314c489ac..7a6f598576 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectAllClientHandler.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectAllClientHandler.java @@ -17,15 +17,11 @@ package org.apache.eventmesh.runtime.admin.handler; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcp2Client; import org.apache.eventmesh.runtime.core.protocol.tcp.client.group.ClientSessionGroupMapping; import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; import org.apache.eventmesh.runtime.util.NetUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.IOException; import java.io.OutputStream; @@ -35,6 +31,12 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; + public class RejectAllClientHandler implements HttpHandler { private static final Logger logger = LoggerFactory.getLogger(RejectAllClientHandler.class); @@ -63,7 +65,8 @@ public void handle(HttpExchange httpExchange) throws IOException { logger.info("rejectAllClient in admin===================="); if (!sessionMap.isEmpty()) { for (Map.Entry entry : sessionMap.entrySet()) { - InetSocketAddress addr = EventMeshTcp2Client.serverGoodby2Client(eventMeshTCPServer, entry.getValue(), clientSessionGroupMapping); + InetSocketAddress addr = EventMeshTcp2Client.serverGoodby2Client( + eventMeshTCPServer, entry.getValue(), clientSessionGroupMapping); if (addr != null) { successRemoteAddrs.add(addr); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java index 83cba95d8a..097ed1416c 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java @@ -17,16 +17,42 @@ package org.apache.eventmesh.runtime.boot; +import org.apache.eventmesh.common.ThreadPoolFactory; +import org.apache.eventmesh.common.protocol.http.HttpCommand; +import org.apache.eventmesh.common.protocol.http.body.Body; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.protocol.http.header.Header; +import org.apache.eventmesh.runtime.common.Pair; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.http.async.AsyncContext; +import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; +import org.apache.eventmesh.runtime.metrics.http.HTTPMetricsServer; +import org.apache.eventmesh.runtime.trace.AttributeKeys; +import org.apache.eventmesh.runtime.trace.OpenTelemetryTraceFactory; +import org.apache.eventmesh.runtime.trace.SpanKey; +import org.apache.eventmesh.runtime.util.RemotingHelper; + +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; + +import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; + import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.google.common.base.Preconditions; import io.netty.bootstrap.ServerBootstrap; @@ -44,6 +70,7 @@ import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.handler.codec.http.HttpHeaderValues; +import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpMethod; import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.HttpRequest; @@ -60,27 +87,15 @@ import io.netty.handler.ssl.SslHandler; import io.netty.handler.timeout.IdleState; import io.netty.handler.timeout.IdleStateEvent; - -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.ObjectUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.common.ThreadPoolFactory; -import org.apache.eventmesh.common.command.HttpCommand; -import org.apache.eventmesh.common.protocol.http.body.Body; -import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; -import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; -import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; -import org.apache.eventmesh.common.protocol.http.common.RequestCode; -import org.apache.eventmesh.common.protocol.http.header.Header; -import org.apache.eventmesh.runtime.common.Pair; -import org.apache.eventmesh.runtime.constants.EventMeshConstants; -import org.apache.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; -import org.apache.eventmesh.runtime.metrics.http.HTTPMetricsServer; -import org.apache.eventmesh.runtime.util.EventMeshUtil; -import org.apache.eventmesh.runtime.util.RemotingHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.api.trace.StatusCode; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import io.opentelemetry.context.propagation.TextMapGetter; +import io.opentelemetry.context.propagation.TextMapPropagator; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; public abstract class AbstractHTTPServer extends AbstractRemotingServer { @@ -96,56 +111,64 @@ public abstract class AbstractHTTPServer extends AbstractRemotingServer { private boolean useTLS; + private Boolean useTrace = true; //Determine whether trace is enabled + + public TextMapPropagator textMapPropagator; + + public OpenTelemetryTraceFactory openTelemetryTraceFactory; + + public Tracer tracer; + public ThreadPoolExecutor asyncContextCompleteHandler = - ThreadPoolFactory.createThreadPoolExecutor(10, 10, "eventMesh-http-asyncContext-"); + ThreadPoolFactory.createThreadPoolExecutor(10, 10, "EventMesh-http-asyncContext-"); static { DiskAttribute.deleteOnExitTemporaryFile = false; } - protected HashMap> processorTable = - new HashMap>(64); + protected final Map> + processorTable = new HashMap<>(64); public AbstractHTTPServer(int port, boolean useTLS) { this.port = port; this.useTLS = useTLS; } - public Map parseHTTPHeader(HttpRequest fullReq) { - Map headerParam = new HashMap<>(); - for (String key : fullReq.headers().names()) { - if (StringUtils.equalsIgnoreCase(HttpHeaderNames.CONTENT_TYPE.toString(), key) - || StringUtils.equalsIgnoreCase(HttpHeaderNames.ACCEPT_ENCODING.toString(), key) - || StringUtils.equalsIgnoreCase(HttpHeaderNames.CONTENT_LENGTH.toString(), key)) { - continue; + public void sendError(ChannelHandlerContext ctx, HttpResponseStatus status) { + FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status); + HttpHeaders responseHeaders = response.headers(); + responseHeaders.add( + HttpHeaderNames.CONTENT_TYPE, String.format("text/plain; charset=%s", EventMeshConstants.DEFAULT_CHARSET) + ); + responseHeaders.add(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes()); + responseHeaders.add(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE); + if (useTrace) { + Context context = ctx.channel().attr(AttributeKeys.SERVER_CONTEXT).get(); + Span span = context.get(SpanKey.SERVER_KEY); + try (Scope ignored = context.makeCurrent()) { + span.setStatus(StatusCode.ERROR); //set this span's status to ERROR + span.end(); // closing the scope does not end the span, this has to be done manually } - headerParam.put(key, fullReq.headers().get(key)); } - return headerParam; - } - - public void sendError(ChannelHandlerContext ctx, - HttpResponseStatus status) { - FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, - status); - response.headers().add(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN + - "; charset=" + EventMeshConstants.DEFAULT_CHARSET); - response.headers().add(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes()); - response.headers().add(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE); - // todo server span end with error, record status, we should get channel here to get span in channel's context in async call.. ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); } - public void sendResponse(ChannelHandlerContext ctx, - DefaultFullHttpResponse response) { - // todo end server span, we should get channel here to get span in channel's context in async call. + public void sendResponse(ChannelHandlerContext ctx, DefaultFullHttpResponse response) { + if (useTrace) { + Context context = ctx.channel().attr(AttributeKeys.SERVER_CONTEXT).get(); + Span span = context.get(SpanKey.SERVER_KEY); + try (Scope ignored = context.makeCurrent()) { + span.end(); + } + } + ctx.writeAndFlush(response).addListener(new ChannelFutureListener() { @Override - public void operationComplete(ChannelFuture f) throws Exception { + public void operationComplete(ChannelFuture f) { if (!f.isSuccess()) { - httpLogger.warn("send response to [{}] fail, will close this channel", RemotingHelper.parseChannelRemoteAddr(f.channel())); + httpLogger.warn("send response to [{}] fail, will close this channel", + RemotingHelper.parseChannelRemoteAddr(f.channel())); f.channel().close(); - return; } } }); @@ -158,9 +181,9 @@ public void start() throws Exception { ServerBootstrap b = new ServerBootstrap(); SSLContext sslContext = useTLS ? SSLContextFactory.getSslContext() : null; b.group(this.bossGroup, this.workerGroup) - .channel(NioServerSocketChannel.class) - .childHandler(new HttpsServerInitializer(sslContext)) - .childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE); + .channel(NioServerSocketChannel.class) + .childHandler(new HttpsServerInitializer(sslContext)) + .childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE); try { httpServerLogger.info("HTTPServer[port={}] started......", this.port); ChannelFuture future = b.bind(this.port).sync(); @@ -176,7 +199,7 @@ public void start() throws Exception { } }; - Thread t = new Thread(r, "eventMesh-http-server"); + Thread t = new Thread(r, "EventMesh-http-server"); t.start(); started.compareAndSet(false, true); } @@ -196,96 +219,164 @@ public void registerProcessor(Integer requestCode, HttpRequestProcessor processo Preconditions.checkState(ObjectUtils.allNotNull(requestCode), "requestCode can't be null"); Preconditions.checkState(ObjectUtils.allNotNull(processor), "processor can't be null"); Preconditions.checkState(ObjectUtils.allNotNull(executor), "executor can't be null"); - Pair pair = new Pair(processor, executor); - this.processorTable.put(requestCode, pair); + Pair pair = new Pair<>(processor, executor); + this.processorTable.put(requestCode.toString(), pair); } - class HTTPHandler extends SimpleChannelInboundHandler { - - @Override - protected void channelRead0(ChannelHandlerContext ctx, HttpRequest httpRequest) throws Exception { - HttpPostRequestDecoder decoder = null; - // todo start server span, we should get channel here to put span in channel's context in async call. - try { - if (!httpRequest.decoderResult().isSuccess()) { - sendError(ctx, HttpResponseStatus.BAD_REQUEST); - return; - } + private Map parseHttpHeader(HttpRequest fullReq) { + Map headerParam = new HashMap<>(); + for (String key : fullReq.headers().names()) { + if (StringUtils.equalsIgnoreCase(HttpHeaderNames.CONTENT_TYPE.toString(), key) + || StringUtils.equalsIgnoreCase(HttpHeaderNames.ACCEPT_ENCODING.toString(), key) + || StringUtils.equalsIgnoreCase(HttpHeaderNames.CONTENT_LENGTH.toString(), key)) { + continue; + } + headerParam.put(key, fullReq.headers().get(key)); + } + return headerParam; + } - final HttpCommand requestCommand = new HttpCommand(); - // todo record command opaque in span. + /** + * Validate request, return error status. + * + * @param httpRequest + * @return if request is validated return null else return error status + */ + private HttpResponseStatus validateHttpRequest(HttpRequest httpRequest) { + if (!started.get()) { + return HttpResponseStatus.SERVICE_UNAVAILABLE; + } + if (!httpRequest.decoderResult().isSuccess()) { + return HttpResponseStatus.BAD_REQUEST; + } + if (!HttpMethod.GET.equals(httpRequest.method()) && !HttpMethod.POST.equals(httpRequest.method())) { + return HttpResponseStatus.METHOD_NOT_ALLOWED; + } + final String protocolVersion = httpRequest.headers().get(ProtocolKey.VERSION); + if (!ProtocolVersion.contains(protocolVersion)) { + return HttpResponseStatus.BAD_REQUEST; + } + return null; + } - httpRequest.headers().set(ProtocolKey.ClientInstanceKey.IP, RemotingHelper.parseChannelRemoteAddr(ctx.channel())); + /** + * Inject ip and protocol version, if the protocol version is empty, set default to {@link ProtocolVersion#V1}. + * + * @param ctx + * @param httpRequest + */ + private void preProcessHttpRequestHeader(ChannelHandlerContext ctx, HttpRequest httpRequest) { + HttpHeaders requestHeaders = httpRequest.headers(); + requestHeaders.set(ProtocolKey.ClientInstanceKey.IP, + RemotingHelper.parseChannelRemoteAddr(ctx.channel())); + + String protocolVersion = httpRequest.headers().get(ProtocolKey.VERSION); + if (StringUtils.isBlank(protocolVersion)) { + requestHeaders.set(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()); + } + } - String protocolVersion = StringUtils.deleteWhitespace(httpRequest.headers().get(ProtocolKey.VERSION)); - if (StringUtils.isBlank(protocolVersion)) { - protocolVersion = ProtocolVersion.V1.getVersion(); - httpRequest.headers().set(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()); + /** + * Parse request body to map + * + * @param httpRequest + * @return + */ + private Map parseHttpRequestBody(HttpRequest httpRequest) throws IOException { + final long bodyDecodeStart = System.currentTimeMillis(); + Map httpRequestBody = new HashMap<>(); + + if (HttpMethod.GET.equals(httpRequest.method())) { + QueryStringDecoder getDecoder = new QueryStringDecoder(httpRequest.uri()); + getDecoder.parameters().forEach((key, value) -> httpRequestBody.put(key, value.get(0))); + } else if (HttpMethod.POST.equals(httpRequest.method())) { + HttpPostRequestDecoder decoder = + new HttpPostRequestDecoder(defaultHttpDataFactory, httpRequest); + for (InterfaceHttpData parm : decoder.getBodyHttpDatas()) { + if (parm.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) { + Attribute data = (Attribute) parm; + httpRequestBody.put(data.getName(), data.getValue()); } + } + decoder.destroy(); + } + metrics.summaryMetrics.recordDecodeTimeCost(System.currentTimeMillis() - bodyDecodeStart); + return httpRequestBody; + } - metrics.summaryMetrics.recordHTTPRequest(); + class HTTPHandler extends SimpleChannelInboundHandler { - long bodyDecodeStart = System.currentTimeMillis(); - - Map bodyMap = new HashMap<>(); - - if (httpRequest.method() == HttpMethod.GET) { - QueryStringDecoder getDecoder = new QueryStringDecoder(httpRequest.uri()); - getDecoder.parameters().entrySet().forEach(entry -> { - bodyMap.put(entry.getKey(), entry.getValue().get(0)); - }); - } else if (httpRequest.method() == HttpMethod.POST) { - decoder = new HttpPostRequestDecoder(defaultHttpDataFactory, httpRequest); - List parmList = decoder.getBodyHttpDatas(); - for (InterfaceHttpData parm : parmList) { - if (parm.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) { - Attribute data = (Attribute) parm; - bodyMap.put(data.getName(), data.getValue()); - } + @Override + protected void channelRead0(ChannelHandlerContext ctx, HttpRequest httpRequest) { + Context context = null; + Span span = null; + if (useTrace) { + //if the client injected span context,this will extract the context from httpRequest or it will be null + context = textMapPropagator.extract(Context.current(), httpRequest, new TextMapGetter() { + @Override + public Iterable keys(HttpRequest carrier) { + return carrier.headers().names(); } - } else { - sendError(ctx, HttpResponseStatus.METHOD_NOT_ALLOWED); + + @Override + public String get(HttpRequest carrier, String key) { + return carrier.headers().get(key); + } + }); + span = tracer.spanBuilder("HTTP " + httpRequest.method()) + .setParent(context) + .setSpanKind(SpanKind.SERVER) + .startSpan(); + //attach the span to the server context + context = context.with(SpanKey.SERVER_KEY, span); + //put the context in channel + ctx.channel().attr(AttributeKeys.SERVER_CONTEXT).set(context); + } + + try { + preProcessHttpRequestHeader(ctx, httpRequest); + final HttpResponseStatus errorStatus = validateHttpRequest(httpRequest); + if (errorStatus != null) { + sendError(ctx, errorStatus); return; } + metrics.summaryMetrics.recordHTTPRequest(); + + final HttpCommand requestCommand = new HttpCommand(); + + final Map bodyMap = parseHttpRequestBody(httpRequest); - metrics.summaryMetrics.recordDecodeTimeCost(System.currentTimeMillis() - bodyDecodeStart); String requestCode = - (httpRequest.method() == HttpMethod.POST) ? StringUtils.deleteWhitespace(httpRequest.headers().get(ProtocolKey.REQUEST_CODE)) - : MapUtils.getString(bodyMap, StringUtils.lowerCase(ProtocolKey.REQUEST_CODE), ""); + (httpRequest.method() == HttpMethod.POST) + ? httpRequest.headers().get(ProtocolKey.REQUEST_CODE) + : MapUtils.getString(bodyMap, StringUtils.lowerCase(ProtocolKey.REQUEST_CODE), ""); requestCommand.setHttpMethod(httpRequest.method().name()); requestCommand.setHttpVersion(httpRequest.protocolVersion().protocolName()); requestCommand.setRequestCode(requestCode); - // todo record command method, version and requestCode in span. - - HttpCommand responseCommand = null; - if (!ProtocolVersion.contains(protocolVersion)) { - responseCommand = requestCommand.createHttpCommandResponse(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg()); - sendResponse(ctx, responseCommand.httpResponse()); - return; + if (useTrace) { + span.setAttribute(SemanticAttributes.HTTP_METHOD, httpRequest.method().name()); + span.setAttribute(SemanticAttributes.HTTP_FLAVOR, httpRequest.protocolVersion().protocolName()); + span.setAttribute(String.valueOf(SemanticAttributes.HTTP_STATUS_CODE), requestCode); } - if (StringUtils.isBlank(requestCode) - || !StringUtils.isNumeric(requestCode) - || !RequestCode.contains(Integer.valueOf(requestCode)) - || !processorTable.containsKey(Integer.valueOf(requestCode))) { - responseCommand = requestCommand.createHttpCommandResponse(EventMeshRetCode.EVENTMESH_REQUESTCODE_INVALID.getRetCode(), EventMeshRetCode.EVENTMESH_REQUESTCODE_INVALID.getErrMsg()); - sendResponse(ctx, responseCommand.httpResponse()); - return; - } + HttpCommand responseCommand = null; - if (!started.get()) { - responseCommand = requestCommand.createHttpCommandResponse(EventMeshRetCode.EVENTMESH_STOP.getRetCode(), EventMeshRetCode.EVENTMESH_STOP.getErrMsg()); + if (StringUtils.isBlank(requestCode) + || !processorTable.containsKey(requestCode) + || !RequestCode.contains(Integer.valueOf(requestCode))) { + responseCommand = + requestCommand.createHttpCommandResponse(EventMeshRetCode.EVENTMESH_REQUESTCODE_INVALID); sendResponse(ctx, responseCommand.httpResponse()); return; } try { - requestCommand.setHeader(Header.buildHeader(requestCode, parseHTTPHeader(httpRequest))); + requestCommand.setHeader(Header.buildHeader(requestCode, parseHttpHeader(httpRequest))); requestCommand.setBody(Body.buildBody(requestCode, bodyMap)); } catch (Exception e) { - responseCommand = requestCommand.createHttpCommandResponse(EventMeshRetCode.EVENTMESH_RUNTIME_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_RUNTIME_ERR.getErrMsg() + EventMeshUtil.stackTrace(e, 3)); + responseCommand = requestCommand.createHttpCommandResponse(EventMeshRetCode.EVENTMESH_RUNTIME_ERR); sendResponse(ctx, responseCommand.httpResponse()); return; } @@ -294,27 +385,32 @@ protected void channelRead0(ChannelHandlerContext ctx, HttpRequest httpRequest) httpLogger.debug("{}", requestCommand); } - AsyncContext asyncContext = new AsyncContext(requestCommand, responseCommand, asyncContextCompleteHandler); + AsyncContext asyncContext = + new AsyncContext<>(requestCommand, responseCommand, asyncContextCompleteHandler); processEventMeshRequest(ctx, asyncContext); } catch (Exception ex) { httpServerLogger.error("AbrstractHTTPServer.HTTPHandler.channelRead0 err", ex); - // todo span end with exception. - } finally { - try { - decoder.destroy(); - } catch (Exception e) { + + if (useTrace) { + span.setAttribute(SemanticAttributes.EXCEPTION_MESSAGE, ex.getMessage()); + span.setStatus(StatusCode.ERROR, ex.getMessage()); //set this span's status to ERROR + span.recordException(ex); //record this exception + span.end(); // closing the scope does not end the span, this has to be done manually } } } public void processEventMeshRequest(final ChannelHandlerContext ctx, final AsyncContext asyncContext) { - final Pair choosed = processorTable.get(Integer.valueOf(asyncContext.getRequest().getRequestCode())); + final HttpCommand request = asyncContext.getRequest(); + final Pair choosed = processorTable.get(request.getRequestCode()); try { choosed.getObject2().submit(() -> { try { - if (choosed.getObject1().rejectRequest()) { - HttpCommand responseCommand = asyncContext.getRequest().createHttpCommandResponse(EventMeshRetCode.EVENTMESH_REJECT_BY_PROCESSOR_ERROR.getRetCode(), EventMeshRetCode.EVENTMESH_REJECT_BY_PROCESSOR_ERROR.getErrMsg()); + HttpRequestProcessor processor = choosed.getObject1(); + if (processor.rejectRequest()) { + HttpCommand responseCommand = + request.createHttpCommandResponse(EventMeshRetCode.EVENTMESH_REJECT_BY_PROCESSOR_ERROR); asyncContext.onComplete(responseCommand); if (asyncContext.isComplete()) { if (httpLogger.isDebugEnabled()) { @@ -325,12 +421,13 @@ public void processEventMeshRequest(final ChannelHandlerContext ctx, return; } - choosed.getObject1().processRequest(ctx, asyncContext); - if (asyncContext == null || !asyncContext.isComplete()) { + processor.processRequest(ctx, asyncContext); + if (!asyncContext.isComplete()) { return; } - metrics.summaryMetrics.recordHTTPReqResTimeCost(System.currentTimeMillis() - asyncContext.getRequest().getReqTime()); + metrics.summaryMetrics + .recordHTTPReqResTimeCost(System.currentTimeMillis() - request.getReqTime()); if (httpLogger.isDebugEnabled()) { httpLogger.debug("{}", asyncContext.getResponse()); @@ -342,13 +439,14 @@ public void processEventMeshRequest(final ChannelHandlerContext ctx, } }); } catch (RejectedExecutionException re) { - HttpCommand responseCommand = asyncContext.getRequest().createHttpCommandResponse(EventMeshRetCode.OVERLOAD.getRetCode(), EventMeshRetCode.OVERLOAD.getErrMsg()); + HttpCommand responseCommand = request.createHttpCommandResponse(EventMeshRetCode.OVERLOAD); asyncContext.onComplete(responseCommand); metrics.summaryMetrics.recordHTTPDiscard(); - metrics.summaryMetrics.recordHTTPReqResTimeCost(System.currentTimeMillis() - responseCommand.getReqTime()); + metrics.summaryMetrics.recordHTTPReqResTimeCost(System.currentTimeMillis() - request.getReqTime()); try { sendResponse(ctx, asyncContext.getResponse().httpResponse()); } catch (Exception e) { + // ignore } } } @@ -360,14 +458,18 @@ public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { } @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - if (null != cause) cause.printStackTrace(); - if (null != ctx) ctx.close(); + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { + if (null != cause) { + logger.error("", cause); + } + if (null != ctx) { + ctx.close(); + } } } class HttpConnectionHandler extends ChannelDuplexHandler { - public AtomicInteger connections = new AtomicInteger(0); + public final AtomicInteger connections = new AtomicInteger(0); @Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { @@ -384,8 +486,9 @@ public void channelActive(ChannelHandlerContext ctx) throws Exception { final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel()); int c = connections.incrementAndGet(); if (c > 20000) { - httpServerLogger.warn("client|http|channelActive|remoteAddress={}|msg={}", remoteAddress, "too many client(20000) connect " + - "this eventMesh server"); + httpServerLogger + .warn("client|http|channelActive|remoteAddress={}|msg={}", remoteAddress, + "too many client(20000) connect this eventMesh server"); ctx.close(); return; } @@ -396,19 +499,17 @@ public void channelActive(ChannelHandlerContext ctx) throws Exception { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { connections.decrementAndGet(); - final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel()); super.channelInactive(ctx); } - @Override - public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { + public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt instanceof IdleStateEvent) { IdleStateEvent event = (IdleStateEvent) evt; if (event.state().equals(IdleState.ALL_IDLE)) { final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel()); - httpServerLogger.info("client|http|userEventTriggered|remoteAddress={}|msg={}", remoteAddress, evt.getClass() - .getName()); + httpServerLogger.info("client|http|userEventTriggered|remoteAddress={}|msg={}", + remoteAddress, evt.getClass().getName()); ctx.close(); } } @@ -419,14 +520,14 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc class HttpsServerInitializer extends ChannelInitializer { - private SSLContext sslContext; + private final SSLContext sslContext; public HttpsServerInitializer(SSLContext sslContext) { this.sslContext = sslContext; } @Override - protected void initChannel(SocketChannel channel) throws Exception { + protected void initChannel(SocketChannel channel) { ChannelPipeline pipeline = channel.pipeline(); @@ -436,10 +537,11 @@ protected void initChannel(SocketChannel channel) throws Exception { pipeline.addFirst("ssl", new SslHandler(sslEngine)); } pipeline.addLast(new HttpRequestDecoder(), - new HttpResponseEncoder(), - new HttpConnectionHandler(), - new HttpObjectAggregator(Integer.MAX_VALUE), - new HTTPHandler()); + new HttpResponseEncoder(), + new HttpConnectionHandler(), + new HttpObjectAggregator(Integer.MAX_VALUE), + new HTTPHandler()); } } + } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractRemotingServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractRemotingServer.java index 02f537dacf..bcf31bfd0b 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractRemotingServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractRemotingServer.java @@ -23,7 +23,7 @@ import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; -import org.apache.eventmesh.common.ThreadUtil; +import org.apache.eventmesh.common.utils.ThreadUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,7 +92,7 @@ public void shutdown() throws Exception { logger.info("shutdown bossGroup"); } - ThreadUtil.randomSleep(30); + ThreadUtils.randomSleep(30); if (ioGroup != null) { ioGroup.shutdownGracefully(); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java new file mode 100644 index 0000000000..ee88ee9c6b --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java @@ -0,0 +1,150 @@ +package org.apache.eventmesh.runtime.boot; + +import io.grpc.Server; +import io.grpc.ServerBuilder; +import org.apache.eventmesh.common.ThreadPoolFactory; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.interceptor.MetricsInterceptor; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.retry.GrpcRetryer; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ConsumerService; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ProducerService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; + +public class EventMeshGrpcServer { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final EventMeshGrpcConfiguration eventMeshGrpcConfiguration; + + private Server server; + + private ProducerManager producerManager; + + private ConsumerManager consumerManager; + + private GrpcRetryer grpcRetryer; + + private ThreadPoolExecutor sendMsgExecutor; + + private ThreadPoolExecutor subscribeMsgExecutor; + + private ThreadPoolExecutor pushMsgExecutor; + + public EventMeshGrpcServer(EventMeshGrpcConfiguration eventMeshGrpcConfiguration) { + this.eventMeshGrpcConfiguration = eventMeshGrpcConfiguration; + } + + public void init() throws Exception { + logger.info("==================EventMeshGRPCServer Initializing=================="); + + initThreadPool(); + + int serverPort = eventMeshGrpcConfiguration.grpcServerPort; + + producerManager = new ProducerManager(this); + producerManager.init(); + + consumerManager = new ConsumerManager(this); + consumerManager.init(); + + grpcRetryer = new GrpcRetryer(this); + grpcRetryer.init(); + + server = ServerBuilder.forPort(serverPort) + .intercept(new MetricsInterceptor()) + .addService(new ProducerService(this, sendMsgExecutor)) + .addService(new ConsumerService(this, subscribeMsgExecutor)) + .build(); + + logger.info("GRPCServer[port={}] started", serverPort); + logger.info("-----------------EventMeshGRPCServer initialized"); + } + + public void start() throws Exception { + logger.info("---------------EventMeshGRPCServer starting-------------------"); + + producerManager.start(); + consumerManager.start(); + grpcRetryer.start(); + server.start(); + + logger.info("---------------EventMeshGRPCServer running-------------------"); + } + + public void shutdown() throws Exception { + logger.info("---------------EventMeshGRPCServer stopping-------------------"); + + producerManager.shutdown(); + consumerManager.shutdown(); + grpcRetryer.shutdown(); + + shutdownThreadPools(); + + server.shutdown(); + + logger.info("---------------EventMeshGRPCServer stopped-------------------"); + } + + public EventMeshGrpcConfiguration getEventMeshGrpcConfiguration() { + return this.eventMeshGrpcConfiguration; + } + + public ProducerManager getProducerManager() { + return producerManager; + } + + public ConsumerManager getConsumerManager() { + return consumerManager; + } + + public GrpcRetryer getGrpcRetryer() { + return grpcRetryer; + } + + public ThreadPoolExecutor getSendMsgExecutor() { + return sendMsgExecutor; + } + + public ThreadPoolExecutor getSubscribeMsgExecutor() { + return subscribeMsgExecutor; + } + + public ThreadPoolExecutor getPushMsgExecutor() { + return pushMsgExecutor; + } + + private void initThreadPool() { + BlockingQueue sendMsgThreadPoolQueue = + new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerSendMsgBlockQSize); + + sendMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerSendMsgThreadNum, + eventMeshGrpcConfiguration.eventMeshServerSendMsgThreadNum, sendMsgThreadPoolQueue, + "eventMesh-grpc-sendMsg-", true); + + BlockingQueue subscribeMsgThreadPoolQueue = + new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgBlockQSize); + + subscribeMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgThreadNum, + eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgThreadNum, subscribeMsgThreadPoolQueue, + "eventMesh-grpc-subscribeMsg-", true); + + BlockingQueue pushMsgThreadPoolQueue = + new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerPushMsgBlockQSize); + pushMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerPushMsgThreadNum, + eventMeshGrpcConfiguration.eventMeshServerPushMsgThreadNum, pushMsgThreadPoolQueue, + "eventMesh-grpc-pushMsg-", true); + } + + private void shutdownThreadPools() { + sendMsgExecutor.shutdown(); + subscribeMsgExecutor.shutdown(); + pushMsgExecutor.shutdown(); + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshHTTPServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshHTTPServer.java index f5055ba4af..8e223f0ee3 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshHTTPServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshHTTPServer.java @@ -17,20 +17,27 @@ package org.apache.eventmesh.runtime.boot; -import com.google.common.eventbus.EventBus; -import com.google.common.util.concurrent.RateLimiter; import org.apache.eventmesh.common.ThreadPoolFactory; import org.apache.eventmesh.common.protocol.http.common.RequestCode; import org.apache.eventmesh.runtime.common.ServiceState; import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; import org.apache.eventmesh.runtime.core.protocol.http.consumer.ConsumerManager; -import org.apache.eventmesh.runtime.core.protocol.http.processor.*; +import org.apache.eventmesh.runtime.core.protocol.http.processor.AdminMetricsProcessor; +import org.apache.eventmesh.runtime.core.protocol.http.processor.BatchSendMessageProcessor; +import org.apache.eventmesh.runtime.core.protocol.http.processor.BatchSendMessageV2Processor; +import org.apache.eventmesh.runtime.core.protocol.http.processor.HeartBeatProcessor; +import org.apache.eventmesh.runtime.core.protocol.http.processor.ReplyMessageProcessor; +import org.apache.eventmesh.runtime.core.protocol.http.processor.SendAsyncMessageProcessor; +import org.apache.eventmesh.runtime.core.protocol.http.processor.SendSyncMessageProcessor; +import org.apache.eventmesh.runtime.core.protocol.http.processor.SubscribeProcessor; +import org.apache.eventmesh.runtime.core.protocol.http.processor.UnSubscribeProcessor; import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.Client; import org.apache.eventmesh.runtime.core.protocol.http.producer.ProducerManager; import org.apache.eventmesh.runtime.core.protocol.http.push.AbstractHTTPPushRequest; import org.apache.eventmesh.runtime.core.protocol.http.retry.HttpRetryer; import org.apache.eventmesh.runtime.metrics.http.HTTPMetricsServer; +import org.apache.eventmesh.runtime.trace.OpenTelemetryTraceFactory; import java.util.List; import java.util.concurrent.BlockingQueue; @@ -38,6 +45,9 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; +import com.google.common.eventbus.EventBus; +import com.google.common.util.concurrent.RateLimiter; + public class EventMeshHTTPServer extends AbstractHTTPServer { private EventMeshServer eventMeshServer; @@ -46,9 +56,11 @@ public class EventMeshHTTPServer extends AbstractHTTPServer { private EventMeshHTTPConfiguration eventMeshHttpConfiguration; - public final ConcurrentHashMap localConsumerGroupMapping = new ConcurrentHashMap<>(); + public final ConcurrentHashMap localConsumerGroupMapping = + new ConcurrentHashMap<>(); - public final ConcurrentHashMap> localClientInfoMapping = new ConcurrentHashMap<>(); + public final ConcurrentHashMap> localClientInfoMapping = + new ConcurrentHashMap<>(); public EventMeshHTTPServer(EventMeshServer eventMeshServer, EventMeshHTTPConfiguration eventMeshHttpConfiguration) { @@ -96,29 +108,45 @@ public void shutdownThreadPool() throws Exception { public void initThreadPool() throws Exception { - BlockingQueue batchMsgThreadPoolQueue = new LinkedBlockingQueue(eventMeshHttpConfiguration.eventMeshServerBatchBlockQSize); - batchMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerBatchMsgThreadNum, - eventMeshHttpConfiguration.eventMeshServerBatchMsgThreadNum, batchMsgThreadPoolQueue, "eventMesh-batchMsg-", true); - - BlockingQueue sendMsgThreadPoolQueue = new LinkedBlockingQueue(eventMeshHttpConfiguration.eventMeshServerSendMsgBlockQSize); - sendMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerSendMsgThreadNum, - eventMeshHttpConfiguration.eventMeshServerSendMsgThreadNum, sendMsgThreadPoolQueue, "eventMesh-sendMsg-", true); - - BlockingQueue pushMsgThreadPoolQueue = new LinkedBlockingQueue(eventMeshHttpConfiguration.eventMeshServerPushMsgBlockQSize); - pushMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerPushMsgThreadNum, - eventMeshHttpConfiguration.eventMeshServerPushMsgThreadNum, pushMsgThreadPoolQueue, "eventMesh-pushMsg-", true); - - BlockingQueue clientManageThreadPoolQueue = new LinkedBlockingQueue(eventMeshHttpConfiguration.eventMeshServerClientManageBlockQSize); - clientManageExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerClientManageThreadNum, - eventMeshHttpConfiguration.eventMeshServerClientManageThreadNum, clientManageThreadPoolQueue, "eventMesh-clientManage-", true); + BlockingQueue batchMsgThreadPoolQueue = + new LinkedBlockingQueue(eventMeshHttpConfiguration.eventMeshServerBatchBlockQSize); + batchMsgExecutor = + ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerBatchMsgThreadNum, + eventMeshHttpConfiguration.eventMeshServerBatchMsgThreadNum, batchMsgThreadPoolQueue, + "eventMesh-batchMsg-", true); + + BlockingQueue sendMsgThreadPoolQueue = + new LinkedBlockingQueue(eventMeshHttpConfiguration.eventMeshServerSendMsgBlockQSize); + sendMsgExecutor = + ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerSendMsgThreadNum, + eventMeshHttpConfiguration.eventMeshServerSendMsgThreadNum, sendMsgThreadPoolQueue, + "eventMesh-sendMsg-", true); + + BlockingQueue pushMsgThreadPoolQueue = + new LinkedBlockingQueue(eventMeshHttpConfiguration.eventMeshServerPushMsgBlockQSize); + pushMsgExecutor = + ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerPushMsgThreadNum, + eventMeshHttpConfiguration.eventMeshServerPushMsgThreadNum, pushMsgThreadPoolQueue, + "eventMesh-pushMsg-", true); + + BlockingQueue clientManageThreadPoolQueue = + new LinkedBlockingQueue(eventMeshHttpConfiguration.eventMeshServerClientManageBlockQSize); + clientManageExecutor = + ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerClientManageThreadNum, + eventMeshHttpConfiguration.eventMeshServerClientManageThreadNum, clientManageThreadPoolQueue, + "eventMesh-clientManage-", true); BlockingQueue adminThreadPoolQueue = new LinkedBlockingQueue(50); - adminExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerAdminThreadNum, - eventMeshHttpConfiguration.eventMeshServerAdminThreadNum, adminThreadPoolQueue, "eventMesh-admin-", true); + adminExecutor = + ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerAdminThreadNum, + eventMeshHttpConfiguration.eventMeshServerAdminThreadNum, adminThreadPoolQueue, "eventMesh-admin-", + true); BlockingQueue replyMessageThreadPoolQueue = new LinkedBlockingQueue(100); - replyMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerReplyMsgThreadNum, - eventMeshHttpConfiguration.eventMeshServerReplyMsgThreadNum, replyMessageThreadPoolQueue, "eventMesh-replyMsg-", true); + replyMsgExecutor = + ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerReplyMsgThreadNum, + eventMeshHttpConfiguration.eventMeshServerReplyMsgThreadNum, replyMessageThreadPoolQueue, + "eventMesh-replyMsg-", true); } public ThreadPoolExecutor getBatchMsgExecutor() { @@ -176,6 +204,10 @@ public void init() throws Exception { registerHTTPRequestProcessor(); + super.openTelemetryTraceFactory = new OpenTelemetryTraceFactory(eventMeshHttpConfiguration); + super.tracer = openTelemetryTraceFactory.getTracer(this.getClass().toString()); + super.textMapPropagator = openTelemetryTraceFactory.getTextMapPropagator(); + logger.info("--------------------------EventMeshHTTPServer inited"); } @@ -210,20 +242,17 @@ public void shutdown() throws Exception { public void registerHTTPRequestProcessor() { BatchSendMessageProcessor batchSendMessageProcessor = new BatchSendMessageProcessor(this); - registerProcessor(RequestCode.MSG_BATCH_SEND.getRequestCode(), - batchSendMessageProcessor, batchMsgExecutor); + registerProcessor(RequestCode.MSG_BATCH_SEND.getRequestCode(), batchSendMessageProcessor, batchMsgExecutor); BatchSendMessageV2Processor batchSendMessageV2Processor = new BatchSendMessageV2Processor(this); - registerProcessor(RequestCode.MSG_BATCH_SEND_V2.getRequestCode(), - batchSendMessageV2Processor, batchMsgExecutor); + registerProcessor(RequestCode.MSG_BATCH_SEND_V2.getRequestCode(), batchSendMessageV2Processor, + batchMsgExecutor); SendSyncMessageProcessor sendSyncMessageProcessor = new SendSyncMessageProcessor(this); - registerProcessor(RequestCode.MSG_SEND_SYNC.getRequestCode(), - sendSyncMessageProcessor, sendMsgExecutor); + registerProcessor(RequestCode.MSG_SEND_SYNC.getRequestCode(), sendSyncMessageProcessor, sendMsgExecutor); SendAsyncMessageProcessor sendAsyncMessageProcessor = new SendAsyncMessageProcessor(this); - registerProcessor(RequestCode.MSG_SEND_ASYNC.getRequestCode(), - sendAsyncMessageProcessor, sendMsgExecutor); + registerProcessor(RequestCode.MSG_SEND_ASYNC.getRequestCode(), sendAsyncMessageProcessor, sendMsgExecutor); AdminMetricsProcessor adminMetricsProcessor = new AdminMetricsProcessor(this); registerProcessor(RequestCode.ADMIN_METRICS.getRequestCode(), adminMetricsProcessor, adminExecutor); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java index ca4733822b..046a93fd44 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java @@ -19,11 +19,13 @@ import org.apache.eventmesh.runtime.acl.Acl; import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; import org.apache.eventmesh.runtime.configuration.EventMeshTCPConfiguration; import org.apache.eventmesh.runtime.connector.ConnectorResource; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.registry.Registry; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,6 +37,10 @@ public class EventMeshServer { private EventMeshTCPServer eventMeshTCPServer; + private EventMeshGrpcServer eventMeshGrpcServer; + + private EventMeshGrpcConfiguration eventMeshGrpcConfiguration; + private EventMeshHTTPConfiguration eventMeshHttpConfiguration; private EventMeshTCPConfiguration eventMeshTCPConfiguration; @@ -48,16 +54,18 @@ public class EventMeshServer { private ServiceState serviceState; public EventMeshServer(EventMeshHTTPConfiguration eventMeshHttpConfiguration, - EventMeshTCPConfiguration eventMeshTCPConfiguration) { + EventMeshTCPConfiguration eventMeshTCPConfiguration, + EventMeshGrpcConfiguration eventMeshGrpcConfiguration) { this.eventMeshHttpConfiguration = eventMeshHttpConfiguration; this.eventMeshTCPConfiguration = eventMeshTCPConfiguration; + this.eventMeshGrpcConfiguration = eventMeshGrpcConfiguration; this.acl = new Acl(); this.registry = new Registry(); this.connectorResource = new ConnectorResource(); } public void init() throws Exception { - if(eventMeshHttpConfiguration != null && eventMeshHttpConfiguration.eventMeshServerSecurityEnable){ + if (eventMeshHttpConfiguration != null && eventMeshHttpConfiguration.eventMeshServerSecurityEnable) { acl.init(eventMeshHttpConfiguration.eventMeshSecurityPluginType); } @@ -67,6 +75,11 @@ public void init() throws Exception { connectorResource.init(eventMeshHttpConfiguration.eventMeshConnectorPluginType); + if (eventMeshGrpcConfiguration != null) { + eventMeshGrpcServer = new EventMeshGrpcServer(eventMeshGrpcConfiguration); + eventMeshGrpcServer.init(); + } + eventMeshHTTPServer = new EventMeshHTTPServer(this, eventMeshHttpConfiguration); eventMeshHTTPServer.init(); eventMeshTCPServer = new EventMeshTCPServer(this, eventMeshTCPConfiguration, registry); @@ -74,7 +87,8 @@ public void init() throws Exception { eventMeshTCPServer.init(); } - String eventStore = System.getProperty(EventMeshConstants.EVENT_STORE_PROPERTIES, System.getenv(EventMeshConstants.EVENT_STORE_ENV)); + String eventStore = System + .getProperty(EventMeshConstants.EVENT_STORE_PROPERTIES, System.getenv(EventMeshConstants.EVENT_STORE_ENV)); logger.info("eventStore : {}", eventStore); serviceState = ServiceState.INITED; @@ -82,14 +96,19 @@ public void init() throws Exception { } public void start() throws Exception { - if(eventMeshHttpConfiguration != null && eventMeshHttpConfiguration.eventMeshServerSecurityEnable){ + if (eventMeshHttpConfiguration != null && eventMeshHttpConfiguration.eventMeshServerSecurityEnable) { acl.start(); } - if (eventMeshTCPConfiguration != null && eventMeshTCPConfiguration.eventMeshTcpServerEnabled && eventMeshTCPConfiguration.eventMeshServerRegistryEnable) { + if (eventMeshTCPConfiguration != null && eventMeshTCPConfiguration.eventMeshTcpServerEnabled && + eventMeshTCPConfiguration.eventMeshServerRegistryEnable) { registry.start(); } + if (eventMeshGrpcConfiguration != null) { + eventMeshGrpcServer.start(); + } + eventMeshHTTPServer.start(); if (eventMeshTCPConfiguration != null && eventMeshTCPConfiguration.eventMeshTcpServerEnabled) { eventMeshTCPServer.start(); @@ -104,20 +123,28 @@ public void shutdown() throws Exception { eventMeshHTTPServer.shutdown(); if (eventMeshTCPConfiguration != null && eventMeshTCPConfiguration.eventMeshTcpServerEnabled) { eventMeshTCPServer.shutdown(); - if(eventMeshTCPConfiguration.eventMeshServerRegistryEnable) { + if (eventMeshTCPConfiguration.eventMeshServerRegistryEnable) { registry.shutdown(); } } connectorResource.release(); - if(eventMeshHttpConfiguration != null && eventMeshHttpConfiguration.eventMeshServerSecurityEnable){ + if (eventMeshGrpcConfiguration != null) { + eventMeshGrpcServer.shutdown(); + } + + if (eventMeshHttpConfiguration != null && eventMeshHttpConfiguration.eventMeshServerSecurityEnable) { acl.shutdown(); } serviceState = ServiceState.STOPED; logger.info("server state:{}", serviceState); } + public EventMeshGrpcServer getEventMeshGrpcServer() { + return eventMeshGrpcServer; + } + public EventMeshHTTPServer getEventMeshHTTPServer() { return eventMeshHTTPServer; } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshStartup.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshStartup.java index 5ad3ba9083..c763358c6e 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshStartup.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshStartup.java @@ -20,6 +20,7 @@ import java.io.File; import org.apache.eventmesh.common.config.ConfigurationWrapper; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; import org.apache.eventmesh.runtime.configuration.EventMeshTCPConfiguration; import org.apache.eventmesh.runtime.constants.EventMeshConstants; @@ -40,7 +41,9 @@ public static void main(String[] args) throws Exception { eventMeshHttpConfiguration.init(); EventMeshTCPConfiguration eventMeshTCPConfiguration = new EventMeshTCPConfiguration(configurationWrapper); eventMeshTCPConfiguration.init(); - EventMeshServer server = new EventMeshServer(eventMeshHttpConfiguration, eventMeshTCPConfiguration); + EventMeshGrpcConfiguration eventMeshGrpcConfiguration = new EventMeshGrpcConfiguration(configurationWrapper); + eventMeshGrpcConfiguration.init(); + EventMeshServer server = new EventMeshServer(eventMeshHttpConfiguration, eventMeshTCPConfiguration, eventMeshGrpcConfiguration); server.init(); server.start(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshTCPServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshTCPServer.java index 6cbb130caf..9c624421f8 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshTCPServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshTCPServer.java @@ -31,8 +31,8 @@ import org.apache.eventmesh.api.registry.dto.EventMeshRegisterInfo; import org.apache.eventmesh.api.registry.dto.EventMeshUnRegisterInfo; -import org.apache.eventmesh.common.EventMeshException; -import org.apache.eventmesh.common.IPUtil; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.utils.IPUtils; import org.apache.eventmesh.common.ThreadPoolFactory; import org.apache.eventmesh.common.protocol.tcp.codec.Codec; import org.apache.eventmesh.runtime.admin.controller.ClientManageController; @@ -287,7 +287,7 @@ private void selfRegisterToRegistry() throws Exception { public boolean registerToRegistry() { boolean registerResult = false; try{ - String endPoints = IPUtil.getLocalAddress() + String endPoints = IPUtils.getLocalAddress() + EventMeshConstants.IP_PORT_SEPARATOR + eventMeshTCPConfiguration.eventMeshTcpServerPort; EventMeshRegisterInfo self = new EventMeshRegisterInfo(); self.setEventMeshClusterName(eventMeshTCPConfiguration.eventMeshCluster); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java new file mode 100644 index 0000000000..7278594eb9 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java @@ -0,0 +1,228 @@ +/* + * Licensed 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.eventmesh.runtime.configuration; + +import com.google.common.base.Preconditions; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.config.CommonConfiguration; +import org.apache.eventmesh.common.config.ConfigurationWrapper; + +public class EventMeshGrpcConfiguration extends CommonConfiguration { + + public int grpcServerPort = 10205; + + public boolean eventMeshServerBatchMsgBatchEnabled = Boolean.TRUE; + + public int eventMeshServerBatchMsgThreadNum = 10; + + public int eventMeshServerSendMsgThreadNum = 8; + + public int eventMeshServerPushMsgThreadNum = 8; + + public int eventMeshServerReplyMsgThreadNum = 8; + + public int eventMeshServerSubscribeMsgThreadNum = 4; + + public int eventMeshServerRegistryThreadNum = 10; + + public int eventMeshServerAdminThreadNum = 2; + + public int eventMeshServerRetryThreadNum = 2; + + public int eventMeshServerPullRegistryInterval = 30000; + + public int eventMeshServerAsyncAccumulationThreshold = 1000; + + public int eventMeshServerRetryBlockQSize = 10000; + + public int eventMeshServerBatchBlockQSize = 1000; + + public int eventMeshServerSendMsgBlockQSize = 1000; + + public int eventMeshServerPushMsgBlockQSize = 1000; + + public int eventMeshServerSubscribeMsgBlockQSize = 1000; + + public int eventMeshServerBusyCheckInterval = 1000; + + public boolean eventMeshServerConsumerEnabled = false; + + public boolean eventMeshServerUseTls = false; + + public int eventMeshBatchMsgRequestNumPerSecond = 20000; + + public EventMeshGrpcConfiguration(ConfigurationWrapper configurationWrapper) { + super(configurationWrapper); + } + + @Override + public void init() { + super.init(); + + if (configurationWrapper != null) { + String httpServerPortStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_GRPC_PORT); + Preconditions.checkState(StringUtils.isNotEmpty(httpServerPortStr) && StringUtils.isNumeric(httpServerPortStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_GRPC_PORT)); + grpcServerPort = Integer.valueOf(StringUtils.deleteWhitespace(httpServerPortStr)); + + String eventMeshServerBatchMsgThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerBatchMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerBatchMsgThreadNumStr)) { + eventMeshServerBatchMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBatchMsgThreadNumStr)); + } + + String eventMeshServerBatchMsgReqNumPerSecondStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_REQ_NUM_PER_SECOND); + if (StringUtils.isNotEmpty(eventMeshServerBatchMsgReqNumPerSecondStr) && StringUtils.isNumeric(eventMeshServerBatchMsgReqNumPerSecondStr)) { + eventMeshBatchMsgRequestNumPerSecond = Integer.valueOf(eventMeshServerBatchMsgReqNumPerSecondStr); + } + + String eventMeshServerBatchMsgBatchEnableStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_BATCH_ENABLED); + if (StringUtils.isNotBlank(eventMeshServerBatchMsgBatchEnableStr)) { + eventMeshServerBatchMsgBatchEnabled = Boolean.valueOf(eventMeshServerBatchMsgBatchEnableStr); + } + + String eventMeshServerAsyncAccumulationThresholdStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ASYNC_ACCUMULATION_THRESHOLD); + if (StringUtils.isNotEmpty(eventMeshServerAsyncAccumulationThresholdStr) && StringUtils.isNumeric(eventMeshServerAsyncAccumulationThresholdStr)) { + eventMeshServerAsyncAccumulationThreshold = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerAsyncAccumulationThresholdStr)); + } + + String eventMeshServerSendMsgThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SENDMSG_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerSendMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerSendMsgThreadNumStr)) { + eventMeshServerSendMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerSendMsgThreadNumStr)); + } + + String eventMeshServerReplyMsgThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_REPLYMSG_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerReplyMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerReplyMsgThreadNumStr)) { + eventMeshServerReplyMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerReplyMsgThreadNumStr)); + } + + String eventMeshServerPushMsgThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_PUSHMSG_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerPushMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerPushMsgThreadNumStr)) { + eventMeshServerPushMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPushMsgThreadNumStr)); + } + + String eventMeshServerRegistryThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_REGISTRY_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerRegistryThreadNumStr) && StringUtils.isNumeric(eventMeshServerRegistryThreadNumStr)) { + eventMeshServerRegistryThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRegistryThreadNumStr)); + } + + String eventMeshServerClientManageThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_CLIENTMANAGE_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerClientManageThreadNumStr) && StringUtils.isNumeric(eventMeshServerClientManageThreadNumStr)) { + eventMeshServerSubscribeMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageThreadNumStr)); + } + + String eventMeshServerPullRegistryIntervalStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_PULL_REGISTRY_INTERVAL); + if (StringUtils.isNotEmpty(eventMeshServerPullRegistryIntervalStr) && StringUtils.isNumeric(eventMeshServerPullRegistryIntervalStr)) { + eventMeshServerPullRegistryInterval = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPullRegistryIntervalStr)); + } + + String eventMeshServerAdminThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ADMIN_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerAdminThreadNumStr) && StringUtils.isNumeric(eventMeshServerAdminThreadNumStr)) { + eventMeshServerAdminThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerAdminThreadNumStr)); + } + + String eventMeshServerRetryBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_RETRY_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerRetryBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerRetryBlockQSizeStr)) { + eventMeshServerRetryBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRetryBlockQSizeStr)); + } + + String eventMeshServerBatchBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_BATCHMSG_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerBatchBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerBatchBlockQSizeStr)) { + eventMeshServerBatchBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBatchBlockQSizeStr)); + } + + String eventMeshServerSendMsgBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_SENDMSG_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerSendMsgBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerSendMsgBlockQSizeStr)) { + eventMeshServerSendMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerSendMsgBlockQSizeStr)); + } + + String eventMeshServerPushMsgBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_PUSHMSG_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerPushMsgBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerPushMsgBlockQSizeStr)) { + eventMeshServerPushMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPushMsgBlockQSizeStr)); + } + + String eventMeshServerClientManageBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_CLIENTM_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerClientManageBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerClientManageBlockQSizeStr)) { + eventMeshServerSubscribeMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageBlockQSizeStr)); + } + + String eventMeshServerBusyCheckIntervalStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_BUSY_CHECK_INTERVAL); + if (StringUtils.isNotEmpty(eventMeshServerBusyCheckIntervalStr) && StringUtils.isNumeric(eventMeshServerBusyCheckIntervalStr)) { + eventMeshServerBusyCheckInterval = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBusyCheckIntervalStr)); + } + + String eventMeshServerConsumerEnabledStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_CONSUMER_ENABLED); + if (StringUtils.isNotEmpty(eventMeshServerConsumerEnabledStr)) { + eventMeshServerConsumerEnabled = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerConsumerEnabledStr)); + } + + String eventMeshServerRetryThreadNumStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_RETRY_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerRetryThreadNumStr) && StringUtils.isNumeric(eventMeshServerRetryThreadNumStr)) { + eventMeshServerRetryThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRetryThreadNumStr)); + } + + String eventMeshServerUseTlsStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_TLS_ENABLED); + if (StringUtils.isNotEmpty(eventMeshServerUseTlsStr)) { + eventMeshServerUseTls = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerUseTlsStr)); + } + } + } + + static class ConfKeys { + + public static String KEYS_EVENTMESH_SERVER_GRPC_PORT = "eventMesh.server.grpc.port"; + + public static String KEYS_EVENTMESH_BATCHMSG_THREAD_NUM = "eventMesh.server.batchmsg.threads.num"; + + public static String KEYS_EVENTMESH_BATCHMSG_REQ_NUM_PER_SECOND = "eventMesh.server.batchmsg.reqNumPerSecond"; + + public static String KEYS_EVENTMESH_BATCHMSG_BATCH_ENABLED = "eventMesh.server.batchmsg.batch.enabled"; + + public static String KEYS_EVENTMESH_ASYNC_ACCUMULATION_THRESHOLD = "eventMesh.server.async.accumulation.threshold"; + + public static String KEY_EVENTMESH_BUSY_CHECK_INTERVAL = "eventMesh.server.busy.check.interval"; + + public static String KEYS_EVENTMESH_SENDMSG_THREAD_NUM = "eventMesh.server.sendmsg.threads.num"; + + public static String KEYS_EVENTMESH_REPLYMSG_THREAD_NUM = "eventMesh.server.replymsg.threads.num"; + + public static String KEYS_EVENTMESH_PUSHMSG_THREAD_NUM = "eventMesh.server.pushmsg.threads.num"; + + public static String KEYS_EVENTMESH_REGISTRY_THREAD_NUM = "eventMesh.server.registry.threads.num"; + + public static String KEYS_EVENTMESH_CLIENTMANAGE_THREAD_NUM = "eventMesh.server.clientmanage.threads.num"; + + public static String KEYS_EVENTMESH_ADMIN_THREAD_NUM = "eventMesh.server.admin.threads.num"; + + public static String KEY_EVENTMESH_RETRY_THREAD_NUM = "eventMesh.server.retry.threads.num"; + + public static String KEYS_EVENTMESH_PULL_REGISTRY_INTERVAL = "eventMesh.server.pull.registry.interval"; + + public static String KEY_EVENTMESH_RETRY_BLOCKQ_SIZE = "eventMesh.server.retry.blockQ.size"; + + public static String KEY_EVENTMESH_BATCHMSG_BLOCKQ_SIZE = "eventMesh.server.batchmsg.blockQ.size"; + + public static String KEY_EVENTMESH_SENDMSG_BLOCKQ_SIZE = "eventMesh.server.sendmsg.blockQ.size"; + + public static String KEY_EVENTMESH_PUSHMSG_BLOCKQ_SIZE = "eventMesh.server.pushmsg.blockQ.size"; + + public static String KEY_EVENTMESH_CLIENTM_BLOCKQ_SIZE = "eventMesh.server.clientM.blockQ.size"; + + public static String KEY_EVENTMESH_CONSUMER_ENABLED = "eventMesh.server.consumer.enabled"; + + public static String KEY_EVENTMESH_TLS_ENABLED = "eventMesh.server.useTls.enabled"; + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java index 810b3f20ce..30cd2648d5 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java @@ -17,6 +17,8 @@ package org.apache.eventmesh.runtime.constants; +import org.apache.eventmesh.common.Constants; + public class EventMeshConstants { public static final String EVENT_STORE_PROPERTIES = "eventstore"; @@ -27,6 +29,8 @@ public class EventMeshConstants { public static final String PROTOCOL_TCP = "tcp"; + public static final String PROTOCOL_GRPC = "grpc"; + public static final String DEFAULT_CHARSET = "UTF-8"; public static final String IP_PORT_SEPARATOR = ":"; @@ -35,19 +39,19 @@ public class EventMeshConstants { public static final String EVENTMESH_CONF_FILE = "eventmesh.properties"; - public static final String REQ_C2EVENTMESH_TIMESTAMP = "req_c2eventMesh_timestamp"; - public static final String REQ_EVENTMESH2MQ_TIMESTAMP = "req_eventMesh2mq_timestamp"; - public static final String REQ_MQ2EVENTMESH_TIMESTAMP = "req_mq2eventMesh_timestamp"; - public static final String REQ_EVENTMESH2C_TIMESTAMP = "req_eventMesh2c_timestamp"; - public static final String RSP_C2EVENTMESH_TIMESTAMP = "rsp_c2eventMesh_timestamp"; - public static final String RSP_EVENTMESH2MQ_TIMESTAMP = "rsp_eventMesh2mq_timestamp"; - public static final String RSP_MQ2EVENTMESH_TIMESTAMP = "rsp_mq2eventMesh_timestamp"; - public static final String RSP_EVENTMESH2C_TIMESTAMP = "rsp_eventMesh2c_timestamp"; + public static final String REQ_C2EVENTMESH_TIMESTAMP = "reqc2eventmeshtimestamp"; + public static final String REQ_EVENTMESH2MQ_TIMESTAMP = "reqeventmesh2mqtimestamp"; + public static final String REQ_MQ2EVENTMESH_TIMESTAMP = "reqmq2eventmeshtimestamp"; + public static final String REQ_EVENTMESH2C_TIMESTAMP = "reqeventmesh2ctimestamp"; + public static final String RSP_C2EVENTMESH_TIMESTAMP = "rspc2eventmeshtimestamp"; + public static final String RSP_EVENTMESH2MQ_TIMESTAMP = "rspeventmesh2mqtimestamp"; + public static final String RSP_MQ2EVENTMESH_TIMESTAMP = "rspmq2eventmeshtimestamp"; + public static final String RSP_EVENTMESH2C_TIMESTAMP = "rspeventmesh2ctimestamp"; - public static final String REQ_SEND_EVENTMESH_IP = "req_send_eventMesh_ip"; - public static final String REQ_RECEIVE_EVENTMESH_IP = "req_receive_eventMesh_ip"; - public static final String RSP_SEND_EVENTMESH_IP = "rsp_send_eventMesh_ip"; - public static final String RSP_RECEIVE_EVENTMESH_IP = "rsp_receive_eventMesh_ip"; + public static final String REQ_SEND_EVENTMESH_IP = "reqsendeventmeship"; + public static final String REQ_RECEIVE_EVENTMESH_IP = "reqreceiveeventmeship"; + public static final String RSP_SEND_EVENTMESH_IP = "rspsendeventmeship"; + public static final String RSP_RECEIVE_EVENTMESH_IP = "rspreceiveeventmeship"; //default TTL 4 hours public static final Integer DEFAULT_MSG_TTL_MILLS = 14400000; @@ -77,23 +81,23 @@ public class EventMeshConstants { public static final String KEYS_UPPERCASE = "KEYS"; public static final String KEYS_LOWERCASE = "keys"; public static final String RR_REQUEST_UNIQ_ID = "RR_REQUEST_UNIQ_ID"; - public static final String TTL = "TTL"; + public static final String TTL = "ttl"; public static final String TAG = "TAG"; - public static final String MANAGE_SUBSYSTEM = "subSystem"; + public static final String MANAGE_SUBSYSTEM = "subsystem"; public static final String MANAGE_IP = "ip"; public static final String MANAGE_PORT = "port"; - public static final String MANAGE_DEST_IP = "desteventMeshIp"; - public static final String MANAGE_DEST_PORT = "desteventMeshPort"; + public static final String MANAGE_DEST_IP = "desteventmeshIp"; + public static final String MANAGE_DEST_PORT = "desteventmeshport"; public static final String MANAGE_PATH = "path"; public static final String MANAGE_GROUP = "group"; public static final String MANAGE_PURPOSE = "purpose"; public static final String MANAGE_TOPIC = "topic"; - public static final String EVENTMESH_SEND_BACK_TIMES = "eventMeshSendBackTimes"; + public static final String EVENTMESH_SEND_BACK_TIMES = "eventmeshdendbacktimes"; - public static final String EVENTMESH_SEND_BACK_IP = "eventMeshSendBackIp"; + public static final String EVENTMESH_SEND_BACK_IP = "eventmeshsendbackip"; public static final String EVENTMESH_REGISTRY_ADDR_KEY = "eventMeshRegistryAddr"; @@ -101,18 +105,20 @@ public class EventMeshConstants { public static final String RR_REPLY_TOPIC = "rr-reply-topic"; - public static final String PROPERTY_MESSAGE_CLUSTER = "CLUSTER"; + public static final String PROPERTY_MESSAGE_CLUSTER = "cluster"; - public static final String PROPERTY_MESSAGE_TTL = "TTL"; + public static final String PROPERTY_MESSAGE_TTL = "ttl"; - public static final String PROPERTY_MESSAGE_KEYS = "KEYS"; + public static final String PROPERTY_MESSAGE_KEYS = "keys"; public static final String PROPERTY_MESSAGE_REPLY_TO = "REPLY_TO"; //requester clientId public static final String PROPERTY_RR_REQUEST_ID = "RR_REQUEST_UNIQ_ID"; - public static final String LEAVE_TIME = "LEAVE_TIME"; //leaveBrokerTime - public static final String ARRIVE_TIME = "ARRIVE_TIME"; - public static final String STORE_TIME = "STORE_TIME"; + public static final String LEAVE_TIME = "leave" + Constants.MESSAGE_PROP_SEPARATOR + "time"; //leaveBrokerTime + public static final String ARRIVE_TIME = "arrive" + Constants.MESSAGE_PROP_SEPARATOR + "time"; + public static final String STORE_TIME = "store" + Constants.MESSAGE_PROP_SEPARATOR + "time"; + + } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQConsumerWrapper.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQConsumerWrapper.java index 68ea786d5a..5d03e81a49 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQConsumerWrapper.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQConsumerWrapper.java @@ -20,11 +20,10 @@ import java.util.List; import java.util.Properties; -import io.openmessaging.api.AsyncMessageListener; -import io.openmessaging.api.Message; - +import io.cloudevents.CloudEvent; import org.apache.eventmesh.api.AbstractContext; -import org.apache.eventmesh.api.consumer.MeshMQPushConsumer; +import org.apache.eventmesh.api.EventListener; +import org.apache.eventmesh.api.consumer.Consumer; import org.apache.eventmesh.api.factory.ConnectorPluginFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +32,7 @@ public class MQConsumerWrapper extends MQWrapper { public Logger logger = LoggerFactory.getLogger(this.getClass()); - protected MeshMQPushConsumer meshMQPushConsumer; + protected Consumer meshMQPushConsumer; public MQConsumerWrapper(String connectorPluginType) { this.meshMQPushConsumer = ConnectorPluginFactory.getMeshMQPushConsumer(connectorPluginType); @@ -43,7 +42,7 @@ public MQConsumerWrapper(String connectorPluginType) { } } - public void subscribe(String topic, AsyncMessageListener listener) throws Exception { + public void subscribe(String topic, EventListener listener) throws Exception { meshMQPushConsumer.subscribe(topic, listener); } @@ -72,7 +71,7 @@ public synchronized void shutdown() throws Exception { // meshMQPushConsumer.registerMessageListener(messageListenerConcurrently); // } - public void updateOffset(List msgs, AbstractContext eventMeshConsumeConcurrentlyContext) { - meshMQPushConsumer.updateOffset(msgs, eventMeshConsumeConcurrentlyContext); + public void updateOffset(List events, AbstractContext eventMeshConsumeConcurrentlyContext) { + meshMQPushConsumer.updateOffset(events, eventMeshConsumeConcurrentlyContext); } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQProducerWrapper.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQProducerWrapper.java index 1c519af63a..f781071126 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQProducerWrapper.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQProducerWrapper.java @@ -19,20 +19,20 @@ import java.util.Properties; -import io.openmessaging.api.Message; -import io.openmessaging.api.SendCallback; - -import org.apache.eventmesh.api.RRCallback; +import org.apache.eventmesh.api.RequestReplyCallback; +import org.apache.eventmesh.api.SendCallback; import org.apache.eventmesh.api.factory.ConnectorPluginFactory; -import org.apache.eventmesh.api.producer.MeshMQProducer; +import org.apache.eventmesh.api.producer.Producer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.cloudevents.CloudEvent; + public class MQProducerWrapper extends MQWrapper { public Logger logger = LoggerFactory.getLogger(this.getClass()); - protected MeshMQProducer meshMQProducer; + protected Producer meshMQProducer; public MQProducerWrapper(String connectorPluginType) { this.meshMQProducer = ConnectorPluginFactory.getMeshMQProducer(connectorPluginType); @@ -76,34 +76,21 @@ public synchronized void shutdown() throws Exception { started.compareAndSet(true, false); } - public void send(Message message, SendCallback sendCallback) throws Exception { - meshMQProducer.send(message, sendCallback); + public void send(CloudEvent cloudEvent, SendCallback sendCallback) throws Exception { + meshMQProducer.publish(cloudEvent, sendCallback); } - public void request(Message message, RRCallback rrCallback, long timeout) + public void request(CloudEvent cloudEvent, RequestReplyCallback rrCallback, long timeout) throws Exception { - meshMQProducer.request(message, rrCallback, timeout); + meshMQProducer.request(cloudEvent, rrCallback, timeout); } - public boolean reply(final Message message, final SendCallback sendCallback) throws Exception { - return meshMQProducer.reply(message, sendCallback); + public boolean reply(final CloudEvent cloudEvent, final SendCallback sendCallback) throws Exception { + return meshMQProducer.reply(cloudEvent, sendCallback); } - public MeshMQProducer getMeshMQProducer() { + public Producer getMeshMQProducer() { return meshMQProducer; } -// public MeshMQProducer getDefaultMQProducer() { -// return meshMQProducer.getDefaultMQProducer(); -// } - -// public static void main(String[] args) throws Exception { -// -// MQProducerWrapper mqProducerWrapper = new MQProducerWrapper(); -// CommonConfiguration commonConfiguration = new CommonConfiguration(new ConfigurationWrapper(EventMeshConstants.EVENTMESH_CONF_HOME -// + File.separator -// + EventMeshConstants.EVENTMESH_CONF_FILE, false)); -// commonConfiguration.init(); -// mqProducerWrapper.init(commonConfiguration, "TEST"); -// } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/cloudevent/OMSMessageFactory.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/cloudevent/OMSMessageFactory.java deleted file mode 100644 index fcb2026fb2..0000000000 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/cloudevent/OMSMessageFactory.java +++ /dev/null @@ -1,99 +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 org.apache.eventmesh.runtime.core.protocol.cloudevent; - -import io.cloudevents.core.message.MessageReader; -import io.cloudevents.core.message.MessageWriter; -import io.cloudevents.core.message.impl.GenericStructuredMessageReader; -import io.cloudevents.core.message.impl.MessageUtils; -import io.cloudevents.lang.Nullable; -import io.cloudevents.rw.CloudEventRWException; -import io.cloudevents.rw.CloudEventWriter; -import io.openmessaging.api.Message; -import org.apache.eventmesh.runtime.core.protocol.cloudevent.impl.OMSBinaryMessageReader; -import org.apache.eventmesh.runtime.core.protocol.cloudevent.impl.OMSHeaders; -import org.apache.eventmesh.runtime.core.protocol.cloudevent.impl.OMSMessageWriter; - -import javax.annotation.ParametersAreNonnullByDefault; -import java.util.Properties; - -/** - * This class provides a collection of methods to create {@link io.cloudevents.core.message.MessageReader} - * and {@link io.cloudevents.core.message.MessageWriter} - * manually serialize/deserialize {@link io.cloudevents.CloudEvent} messages. - */ -@ParametersAreNonnullByDefault -public final class OMSMessageFactory { - - private OMSMessageFactory() { - // prevent instantiation - } - - /** - * create reader by message - * @param message - * @return - * @throws CloudEventRWException - */ - public static MessageReader createReader(final Message message) throws CloudEventRWException { - return createReader(message.getUserProperties(), message.getBody()); - } - - - public static MessageReader createReader(final Properties props, @Nullable final byte[] body) throws CloudEventRWException { - - return MessageUtils.parseStructuredOrBinaryMessage( - () -> props.getOrDefault(OMSHeaders.CONTENT_TYPE,"").toString(), - format -> new GenericStructuredMessageReader(format, body), - () -> props.getOrDefault(OMSHeaders.SPEC_VERSION,"").toString(), - sv -> new OMSBinaryMessageReader(sv, props, body) - ); - } - - - /** - * create writer by topic - * @param topic - * @return - */ - public static MessageWriter, Message> createWriter(String topic) { - return new OMSMessageWriter<>(topic); - } - - /** - * create writer by topic,keys - * @param topic - * @param keys - * @return - */ - public static MessageWriter, Message> createWriter(String topic, String keys) { - return new OMSMessageWriter<>(topic, keys); - } - - /** - * create writer by topic,keys,tags - * @param topic - * @param keys - * @param tags - * @return - */ - public static MessageWriter, Message> createWriter(String topic, String keys, String tags) { - return new OMSMessageWriter<>(topic, keys, tags); - } - -} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/cloudevent/impl/OMSBinaryMessageReader.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/cloudevent/impl/OMSBinaryMessageReader.java deleted file mode 100644 index ae035c7be8..0000000000 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/cloudevent/impl/OMSBinaryMessageReader.java +++ /dev/null @@ -1,90 +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 org.apache.eventmesh.runtime.core.protocol.cloudevent.impl; - -import io.cloudevents.SpecVersion; -import io.cloudevents.core.data.BytesCloudEventData; -import io.cloudevents.core.message.impl.BaseGenericBinaryMessageReaderImpl; - -import java.util.Objects; -import java.util.Properties; -import java.util.function.BiConsumer; - -/** - * binary message reader - */ -public class OMSBinaryMessageReader extends BaseGenericBinaryMessageReaderImpl { - - private final Properties headers; - - public OMSBinaryMessageReader(SpecVersion version, Properties headers, byte[] payload) { - super(version, payload != null && payload.length > 0 ? BytesCloudEventData.wrap(payload) : null); - - Objects.requireNonNull(headers); - this.headers = headers; - } - - /** - * whether header key is content type - * @param key - * @return - */ - @Override - protected boolean isContentTypeHeader(String key) { - return key.equals(OMSHeaders.CONTENT_TYPE); - } - - /** - * whether message header is cloudEvent header - * @param key - * @return - */ - @Override - protected boolean isCloudEventsHeader(String key) { - return key.length() > 3 && key.substring(0, OMSHeaders.CE_PREFIX.length()).startsWith(OMSHeaders.CE_PREFIX); - } - - /** - * parse message header to cloudEvent attribute - * @param key - * @return - */ - @Override - protected String toCloudEventsKey(String key) { - return key.substring(OMSHeaders.CE_PREFIX.length()).toLowerCase(); - } - - /** - * - * @param fn - */ - @Override - protected void forEachHeader(BiConsumer fn) { - this.headers.forEach((k, v) -> { - if (k != null && v != null) { - fn.accept(k.toString(), v.toString()); - } - - }); - } - - @Override - protected String toCloudEventsValue(String value) { - return value; - } -} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/cloudevent/impl/OMSHeaders.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/cloudevent/impl/OMSHeaders.java deleted file mode 100644 index 7747175165..0000000000 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/cloudevent/impl/OMSHeaders.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 org.apache.eventmesh.runtime.core.protocol.cloudevent.impl; - -import io.cloudevents.core.message.impl.MessageUtils; -import io.cloudevents.core.v1.CloudEventV1; - -import java.util.Map; - -/** - * Define the value of CE attribute in the header of ons - */ -public class OMSHeaders { - - /** - * CE prefix - */ - public static final String CE_PREFIX = "ce_"; - - /** - * Prefix each value - */ - protected static final Map ATTRIBUTES_TO_HEADERS = MessageUtils.generateAttributesToHeadersMapping(v -> CE_PREFIX + v); - - public static final String CONTENT_TYPE = ATTRIBUTES_TO_HEADERS.get(CloudEventV1.DATACONTENTTYPE); - - public static final String SPEC_VERSION = ATTRIBUTES_TO_HEADERS.get(CloudEventV1.SPECVERSION); - -} - diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/cloudevent/impl/OMSMessageWriter.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/cloudevent/impl/OMSMessageWriter.java deleted file mode 100644 index 0d74331a06..0000000000 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/cloudevent/impl/OMSMessageWriter.java +++ /dev/null @@ -1,100 +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 org.apache.eventmesh.runtime.core.protocol.cloudevent.impl; - -import io.cloudevents.CloudEventData; -import io.cloudevents.SpecVersion; -import io.cloudevents.core.format.EventFormat; -import io.cloudevents.core.message.MessageWriter; -import io.cloudevents.rw.CloudEventContextWriter; -import io.cloudevents.rw.CloudEventRWException; -import io.cloudevents.rw.CloudEventWriter; -import io.openmessaging.api.Message; -import org.apache.commons.lang3.StringUtils; - -/** - * write ce to ons - * @param - */ -public final class OMSMessageWriter implements MessageWriter, Message>, CloudEventWriter { - - private Message message; - - - public OMSMessageWriter(String topic) { - message = new Message(); - message.setTopic(topic); - } - - public OMSMessageWriter(String topic, String key) { - message = new Message(); - message.setTopic(topic); - if (key != null && key.length() > 0) { - message.setKey(key); - } - } - - public OMSMessageWriter(String topic, String key, String tag) { - message = new Message(); - message.setTopic(topic); - if (StringUtils.isNotEmpty(tag)) { - message.setTag(tag); - } - - if (StringUtils.isNotEmpty(key)) { - message.setKey(key); - } - } - - - @Override - public CloudEventContextWriter withContextAttribute(String name, String value) throws CloudEventRWException { - - String propName = OMSHeaders.ATTRIBUTES_TO_HEADERS.get(name); - if (propName == null) { - propName = OMSHeaders.CE_PREFIX + name; - } - message.putUserProperties(propName, value); - return this; - } - - @Override - public OMSMessageWriter create(final SpecVersion version) { - message.putUserProperties(OMSHeaders.SPEC_VERSION, version.toString()); - return this; - } - - @Override - public Message setEvent(final EventFormat format, final byte[] value) throws CloudEventRWException { - message.putUserProperties(OMSHeaders.CONTENT_TYPE, format.serializedContentType()); - message.setBody(value); - return message; - } - - @Override - public Message end(final CloudEventData data) throws CloudEventRWException { - message.setBody(data.toBytes()); - return message; - } - - @Override - public Message end() { - message.setBody(null); - return message; - } -} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java new file mode 100644 index 0000000000..fcf414e5ad --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java @@ -0,0 +1,110 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.consumer; + +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +public class ConsumerManager { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final EventMeshGrpcServer eventMeshGrpcServer; + + // key: ConsumerGroup + private final Map> clientTable = new ConcurrentHashMap<>(); + + // key: ConsumerGroup + private final Map consumerTable = new ConcurrentHashMap<>(); + + public ConsumerManager(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void init() throws Exception { + logger.info("Grpc ConsumerManager initialized......"); + } + + public void start() throws Exception { + logger.info("Grpc ConsumerManager started......"); + } + + public void shutdown() throws Exception { + for (EventMeshConsumer consumer : consumerTable.values()) { + consumer.shutdown(); + } + logger.info("Grpc ConsumerManager shutdown......"); + } + + public synchronized void registerClient(ConsumerGroupClient newClient) { + String consumerGroup = newClient.getConsumerGroup(); + String topic = newClient.getTopic(); + String url = newClient.getUrl(); + SubscriptionMode subscriptionMode = newClient.getSubscriptionMode(); + List localClients = clientTable.get(consumerGroup); + + if (localClients == null) { + localClients = new ArrayList<>(); + localClients.add(newClient); + clientTable.put(consumerGroup, localClients); + } else { + boolean isContains = false; + for (ConsumerGroupClient localClient : localClients) { + if (StringUtils.equals(localClient.getTopic(), topic) && StringUtils.equals(localClient.getUrl(), url) + && localClient.getSubscriptionMode().equals(subscriptionMode)) { + isContains = true; + localClient.setLastUpTime(newClient.getLastUpTime()); + break; + } + } + if (!isContains) { + localClients.add(newClient); + } + } + } + + public void restartEventMeshConsumer(String consumerGroup) throws Exception { + EventMeshConsumer eventMeshConsumer = consumerTable.get(consumerGroup); + + if (eventMeshConsumer == null) { + eventMeshConsumer = new EventMeshConsumer(eventMeshGrpcServer, consumerGroup); + consumerTable.put(consumerGroup, eventMeshConsumer); + eventMeshConsumer.init(); + } + + Set oldTopicConfigs = eventMeshConsumer.buildTopicConfig(); + List localClients = clientTable.get(consumerGroup); + for (ConsumerGroupClient client : localClients) { + String topic = client.getTopic(); + String idc = client.getIdc(); + String url = client.getUrl(); + SubscriptionMode subscriptionMode = client.getSubscriptionMode(); + eventMeshConsumer.addTopicConfig(topic, subscriptionMode, idc, url); + } + + // start up eventMeshConsumer the first time + if (ServiceState.INITED.equals(eventMeshConsumer.getStatus())) { + eventMeshConsumer.start(); + return; + } + + // determine if restart eventMeshConsumer required + Set newTopicConfigs = eventMeshConsumer.buildTopicConfig(); + if (!oldTopicConfigs.equals(newTopicConfigs)) { + logger.info("Consumergroup {} topic info changed, restart EventMeshConsumer.", consumerGroup); + if (ServiceState.RUNNING.equals(eventMeshConsumer.getStatus())) { + eventMeshConsumer.shutdown(); + } + eventMeshConsumer.start(); + } + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java new file mode 100644 index 0000000000..735f85ffb3 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java @@ -0,0 +1,235 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.consumer; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.api.EventListener; +import org.apache.eventmesh.api.EventMeshAction; +import org.apache.eventmesh.api.EventMeshAsyncConsumeContext; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.plugin.MQConsumerWrapper; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupTopicConfig; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.EventMeshProducer; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.SendMessageContext; +import org.apache.eventmesh.runtime.core.protocol.grpc.push.HTTPMessageHandler; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +public class EventMeshConsumer { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final String consumerGroup; + + private final EventMeshGrpcServer eventMeshGrpcServer; + + private final EventMeshGrpcConfiguration eventMeshGrpcConfiguration; + + private final MQConsumerWrapper persistentMqConsumer; + + private final MQConsumerWrapper broadcastMqConsumer; + + private final HTTPMessageHandler httpMessageHandler; + + private ServiceState serviceState; + + /** + * Key: topic + * Value: ConsumerGroupTopicConfig + **/ + private final Map consumerGroupTopicConfig = new ConcurrentHashMap<>(); + + public EventMeshConsumer(EventMeshGrpcServer eventMeshGrpcServer, String consumerGroup) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + this.eventMeshGrpcConfiguration = eventMeshGrpcServer.getEventMeshGrpcConfiguration(); + this.consumerGroup = consumerGroup; + this.httpMessageHandler = new HTTPMessageHandler(consumerGroup, eventMeshGrpcServer.getPushMsgExecutor()); + this.persistentMqConsumer = new MQConsumerWrapper(eventMeshGrpcConfiguration.eventMeshConnectorPluginType); + this.broadcastMqConsumer = new MQConsumerWrapper(eventMeshGrpcConfiguration.eventMeshConnectorPluginType); + } + + public synchronized void addTopicConfig(String topic, SubscriptionMode subscriptionMode, String idc, String url) { + ConsumerGroupTopicConfig topicConfig = consumerGroupTopicConfig.get(topic); + if (topicConfig == null) { + topicConfig = new ConsumerGroupTopicConfig(consumerGroup, topic, subscriptionMode); + consumerGroupTopicConfig.put(topic, topicConfig); + } + topicConfig.addUrl(idc, url); + } + + public synchronized Set buildTopicConfig() { + Set topicConfigs = new HashSet<>(); + for (ConsumerGroupTopicConfig topicConfig : consumerGroupTopicConfig.values()) { + topicConfigs.add(topicConfig.getTopic() + topicConfig.getSubscriptionMode().name()); + } + return topicConfigs; + } + + public synchronized void init() throws Exception { + Properties keyValue = new Properties(); + keyValue.put("isBroadcast", "false"); + keyValue.put("consumerGroup", consumerGroup); + keyValue.put("eventMeshIDC", eventMeshGrpcConfiguration.eventMeshIDC); + keyValue.put("instanceName", EventMeshUtil.buildMeshClientID(consumerGroup, + eventMeshGrpcConfiguration.eventMeshCluster)); + persistentMqConsumer.init(keyValue); + + Properties broadcastKeyValue = new Properties(); + broadcastKeyValue.put("isBroadcast", "true"); + broadcastKeyValue.put("consumerGroup", consumerGroup); + broadcastKeyValue.put("eventMeshIDC", eventMeshGrpcConfiguration.eventMeshIDC); + broadcastKeyValue.put("instanceName", EventMeshUtil.buildMeshClientID(consumerGroup, + eventMeshGrpcConfiguration.eventMeshCluster)); + broadcastMqConsumer.init(broadcastKeyValue); + + serviceState = ServiceState.INITED; + logger.info("EventMeshConsumer [{}] initialized.............", consumerGroup); + } + + public synchronized void start() throws Exception { + for (Map.Entry entry : consumerGroupTopicConfig.entrySet()) { + subscribe(entry.getKey(), entry.getValue().getSubscriptionMode()); + } + + persistentMqConsumer.start(); + broadcastMqConsumer.start(); + + serviceState = ServiceState.RUNNING; + logger.info("EventMeshConsumer [{}] started..........", consumerGroup); + } + + public synchronized void shutdown() throws Exception { + persistentMqConsumer.shutdown(); + broadcastMqConsumer.shutdown(); + + serviceState = ServiceState.STOPED; + logger.info("EventMeshConsumer [{}] shutdown.........", consumerGroup); + } + + public ServiceState getStatus() { + return serviceState; + } + + public void subscribe(String topic, SubscriptionMode subscriptionMode) throws Exception { + if (SubscriptionMode.CLUSTERING.equals(subscriptionMode)) { + persistentMqConsumer.subscribe(topic, createEventListener(subscriptionMode)); + } else if (SubscriptionMode.BROADCASTING.equals(subscriptionMode)) { + broadcastMqConsumer.subscribe(topic, createEventListener(subscriptionMode)); + } else { + logger.error("Subscribe Failed. Incorrect Subscription Mode"); + throw new Exception("Subscribe Failed. Incorrect Subscription Mode"); + } + } + + public void unsubscribe(Subscription.SubscriptionItem subscriptionItem) throws Exception { + SubscriptionMode mode = subscriptionItem.getMode(); + String topic = subscriptionItem.getTopic(); + if (SubscriptionMode.CLUSTERING.equals(mode)) { + persistentMqConsumer.unsubscribe(topic); + } else if (SubscriptionMode.BROADCASTING.equals(mode)) { + broadcastMqConsumer.unsubscribe(topic); + } else { + logger.error("Unsubscribe Failed. Incorrect Subscription Mode"); + throw new Exception("Unsubscribe Failed. Incorrect Subscription Mode"); + } + } + + public void updateOffset(SubscriptionMode subscriptionMode, List events, + AbstractContext context) throws Exception { + if (SubscriptionMode.CLUSTERING.equals(subscriptionMode)) { + persistentMqConsumer.updateOffset(events, context); + } else if (SubscriptionMode.BROADCASTING.equals(subscriptionMode)) { + broadcastMqConsumer.updateOffset(events, context); + } else { + logger.error("Subscribe Failed. Incorrect Subscription Mode"); + throw new Exception("Subscribe Failed. Incorrect Subscription Mode"); + } + } + + private EventListener createEventListener(SubscriptionMode subscriptionMode) { + return (event, context) -> { + + event = CloudEventBuilder.from(event) + .withExtension(EventMeshConstants.REQ_MQ2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .build(); + + String topic = event.getSubject(); + Object bizSeqNo = event.getExtension(Constants.PROPERTY_MESSAGE_SEARCH_KEYS); + String strBizSeqNo = bizSeqNo == null ? "" : bizSeqNo.toString(); + + Object uniqueId = event.getExtension(Constants.RMB_UNIQ_ID); + String strUniqueId = uniqueId == null ? "" : uniqueId.toString(); + + if (logger.isDebugEnabled()) { + logger.debug("message|mq2eventMesh|topic={}|msg={}", topic, event); + } else { + logger.info("message|mq2eventMesh|topic={}|bizSeqNo={}|uniqueId={}", topic, bizSeqNo, uniqueId); + } + + EventMeshAsyncConsumeContext eventMeshAsyncConsumeContext = (EventMeshAsyncConsumeContext) context; + + ConsumerGroupTopicConfig topicConfig = consumerGroupTopicConfig.get(topic); + if (topicConfig != null) { + HandleMsgContext handleMsgContext = new HandleMsgContext(EventMeshUtil.buildPushMsgSeqNo(), consumerGroup, + this, + topic, event, subscriptionMode, eventMeshAsyncConsumeContext.getAbstractContext(), eventMeshGrpcServer, strBizSeqNo, strUniqueId, + topicConfig); + + if (httpMessageHandler.handle(handleMsgContext)) { + eventMeshAsyncConsumeContext.commit(EventMeshAction.ManualAck); + return; + } else { + // can not handle the message due to the capacity limit is reached + // wait for sometime and send this message back to mq and consume again + try { + Thread.sleep(5000); + sendMessageBack(consumerGroup, event, strUniqueId, strBizSeqNo); + } catch (Exception ignored) { + // ignore exception + } + } + } + eventMeshAsyncConsumeContext.commit(EventMeshAction.CommitMessage); + }; + } + + public void sendMessageBack(String consumerGroup, final CloudEvent event, final String uniqueId, String bizSeqNo) throws Exception { + EventMeshProducer producer + = eventMeshGrpcServer.getProducerManager().getEventMeshProducer(consumerGroup); + + if (producer == null) { + logger.warn("consumer:{} consume fail, sendMessageBack, bizSeqNo:{}, uniqueId:{}", consumerGroup, bizSeqNo, uniqueId); + return; + } + + final SendMessageContext sendMessageBackContext = new SendMessageContext(bizSeqNo, event, producer, eventMeshGrpcServer); + + producer.send(sendMessageBackContext, new SendCallback() { + @Override + public void onSuccess(SendResult sendResult) { + } + + @Override + public void onException(OnExceptionContext context) { + logger.warn("consumer:{} consume fail, sendMessageBack, bizSeqNo:{}, uniqueId:{}", consumerGroup, bizSeqNo, uniqueId); + } + }); + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/HandleMsgContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/HandleMsgContext.java new file mode 100644 index 0000000000..9135dabbe9 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/HandleMsgContext.java @@ -0,0 +1,178 @@ +/* + * Licensed 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.eventmesh.runtime.core.protocol.grpc.consumer; + +import io.cloudevents.CloudEvent; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupTopicConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Collections; + +public class HandleMsgContext { + + private final String msgRandomNo; + private final SubscriptionMode subscriptionMode; + private final EventMeshGrpcServer eventMeshGrpcServer; + private final ConsumerGroupTopicConfig consumeTopicConfig; + public Logger messageLogger = LoggerFactory.getLogger("message"); + private String consumerGroup; + private EventMeshConsumer eventMeshConsumer; + private String bizSeqNo; + private String uniqueId; + private String topic; + private CloudEvent event; + private int ttl; + private long createTime = System.currentTimeMillis(); + private AbstractContext context; + + public HandleMsgContext(String msgRandomNo, String consumerGroup, EventMeshConsumer eventMeshConsumer, + String topic, CloudEvent event, SubscriptionMode subscriptionMode, + AbstractContext context, EventMeshGrpcServer eventMeshGrpcServer, + String bizSeqNo, String uniqueId, ConsumerGroupTopicConfig consumeTopicConfig) { + this.msgRandomNo = msgRandomNo; + this.consumerGroup = consumerGroup; + this.eventMeshConsumer = eventMeshConsumer; + this.topic = topic; + this.subscriptionMode = subscriptionMode; + this.event = event; + this.context = context; + this.eventMeshGrpcServer = eventMeshGrpcServer; + this.bizSeqNo = bizSeqNo; + this.uniqueId = uniqueId; + this.consumeTopicConfig = consumeTopicConfig; + + String ttlStr = (String) event.getExtension(Constants.PROPERTY_MESSAGE_TIMEOUT); + this.ttl = StringUtils.isNumeric(ttlStr) ? Integer.parseInt(ttlStr) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS; + } + + public String getMsgRandomNo() { + return msgRandomNo; + } + + public ConsumerGroupTopicConfig getConsumeTopicConfig() { + return consumeTopicConfig; + } + + public String getBizSeqNo() { + return bizSeqNo; + } + + public void setBizSeqNo(String bizSeqNo) { + this.bizSeqNo = bizSeqNo; + } + + public String getConsumerGroup() { + return consumerGroup; + } + + public void setConsumerGroup(String consumerGroup) { + this.consumerGroup = consumerGroup; + } + + public EventMeshConsumer getEventMeshConsumer() { + return eventMeshConsumer; + } + + public void setEventMeshConsumer(EventMeshConsumer eventMeshConsumer) { + this.eventMeshConsumer = eventMeshConsumer; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public CloudEvent getEvent() { + return event; + } + + public void setEvent(CloudEvent event) { + this.event = event; + } + + public long getCreateTime() { + return createTime; + } + + public void setCreateTime(long createTime) { + this.createTime = createTime; + } + + public AbstractContext getContext() { + return context; + } + + public void setContext(AbstractContext context) { + this.context = context; + } + + public EventMeshGrpcServer getEventMeshGrpcServer() { + return eventMeshGrpcServer; + } + + public void finish() { + if (eventMeshConsumer != null && context != null && event != null) { + try { + eventMeshConsumer.updateOffset(subscriptionMode, Collections.singletonList(event), context); + } catch (Exception e) { + messageLogger.error("Error in updating offset in EventMeshConsumer", e); + } + } + } + + public String getUniqueId() { + return uniqueId; + } + + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } + + public int getTtl() { + return ttl; + } + + public void setTtl(int ttl) { + this.ttl = ttl; + } + + @Override + public String toString() { + return "handleMsgContext={" + + "consumerGroup=" + consumerGroup + + ",topic=" + topic + + ",subscriptionMode=" + subscriptionMode + + ",consumeTopicConfig=" + consumeTopicConfig + + ",bizSeqNo=" + bizSeqNo + + ",uniqueId=" + uniqueId + + ",ttl=" + ttl + + ",createTime=" + DateFormatUtils.format(createTime, Constants.DATE_FORMAT) + "}"; + } + +} diff --git a/eventmesh-registry-plugin/eventmesh-registry-namesrv/build.gradle b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/MessageHandler.java similarity index 82% rename from eventmesh-registry-plugin/eventmesh-registry-namesrv/build.gradle rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/MessageHandler.java index 8471545fe0..708af0fa8a 100644 --- a/eventmesh-registry-plugin/eventmesh-registry-namesrv/build.gradle +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/MessageHandler.java @@ -14,8 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -dependencies { - compileOnly project(":eventmesh-registry-plugin:eventmesh-registry-api") - testImplementation project(":eventmesh-registry-plugin:eventmesh-registry-api") +package org.apache.eventmesh.runtime.core.protocol.grpc.consumer; + +public interface MessageHandler { + boolean handle(HandleMsgContext handleMsgContext); } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java new file mode 100644 index 0000000000..7192b3321f --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java @@ -0,0 +1,72 @@ +/* + * Licensed to 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. Apache Software Foundation (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.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; + +import lombok.Builder; +import lombok.Data; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; + +import java.util.Date; + +@Builder +@Data +public class ConsumerGroupClient { + + private String env; + + private String idc; + + private String consumerGroup; + + private String topic; + + private String url; + + private SubscriptionMode subscriptionMode; + + private String sys; + + private String ip; + + private String pid; + + private String hostname; + + private String apiVersion; + + private Date lastUpTime; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("endPoint={env=").append(env) + .append(",idc=").append(idc) + .append(",consumerGroup=").append(consumerGroup) + .append(",topic=").append(topic) + .append(",url=").append(url) + .append(",sys=").append(sys) + .append(",ip=").append(ip) + .append(",pid=").append(pid) + .append(",hostname=").append(hostname) + .append(",apiVersion=").append(apiVersion) + .append(",registerTime=").append("}"); + return sb.toString(); + } +} + diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java new file mode 100644 index 0000000000..d477ddb1ba --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java @@ -0,0 +1,88 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; + +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + +public class ConsumerGroupTopicConfig { + public static Logger logger = LoggerFactory.getLogger(ConsumerGroupTopicConfig.class); + + private String consumerGroup; + + private String topic; + + private SubscriptionMode subscriptionMode; + + /** + * PUSH URL + *

+ * Key: IDC + * Value: list of URls + */ + private Map> idcUrls = new ConcurrentHashMap<>(); + + public ConsumerGroupTopicConfig(String consumerGroup, String topic, SubscriptionMode subscriptionMode) { + this.consumerGroup = consumerGroup; + this.topic = topic; + this.subscriptionMode = subscriptionMode; + } + + public synchronized void addUrl(String idc, String url) { + List urls = idcUrls.get(idc); + if (urls == null) { + urls = new ArrayList<>(); + urls.add(url); + idcUrls.put(idc, urls); + } else if (!urls.contains(url)) { + urls.add(url); + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConsumerGroupTopicConfig that = (ConsumerGroupTopicConfig) o; + return consumerGroup.equals(that.consumerGroup) + && Objects.equals(topic, that.topic) + && Objects.equals(idcUrls, that.idcUrls); + } + + @Override + public int hashCode() { + return Objects.hash(consumerGroup, topic, idcUrls); + } + + @Override + public String toString() { + return "consumeTopicConfig={consumerGroup=" + consumerGroup + + ",topic=" + topic + + ",idcUrls=" + idcUrls + "}"; + } + + public String getConsumerGroup() { + return consumerGroup; + } + + public String getTopic() { + return topic; + } + + public SubscriptionMode getSubscriptionMode() { + return subscriptionMode; + } + + public Map> getIdcUrls() { + return idcUrls; + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java new file mode 100644 index 0000000000..5b7df16cd7 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java @@ -0,0 +1,24 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.interceptor; + +import io.grpc.Grpc; +import io.grpc.Metadata; +import io.grpc.ServerCall; +import io.grpc.ServerCallHandler; +import io.grpc.ServerInterceptor; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MetricsInterceptor implements ServerInterceptor { + + private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + @Override + public ServerCall.Listener interceptCall( + ServerCall call, Metadata headers, ServerCallHandler next) { + logger.info("cmd={}|{}|client2eventMesh|from={}|to={}", call.getMethodDescriptor().getFullMethodName(), + EventMeshConstants.PROTOCOL_GRPC, call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR),IPUtils.getLocalAddress()); + return next.startCall(call, headers); + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java new file mode 100644 index 0000000000..efc3e9a1bd --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java @@ -0,0 +1,100 @@ +/* + * Licensed 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.eventmesh.runtime.core.protocol.grpc.processor; + +import io.cloudevents.CloudEvent; +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.EventMeshProducer; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.SendMessageContext; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SendAsyncMessageProcessor { + + private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + private EventMeshGrpcServer eventMeshGrpcServer; + + public SendAsyncMessageProcessor(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void process(EventMeshMessage message, StreamObserver responseObserver) throws Exception { + RequestHeader requestHeader = message.getHeader(); + + if (!ServiceUtils.validateHeader(requestHeader)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + return; + } + + if (!ServiceUtils.validateMessage(message)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + return; + } + + String protocolType = requestHeader.getProtocolType(); + ProtocolAdaptor grpcCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + CloudEvent cloudEvent = grpcCommandProtocolAdaptor.toCloudEvent(new EventMeshMessageWrapper(message)); + + String seqNum = message.getSeqNum(); + String uniqueId = message.getUniqueId(); + String topic = message.getTopic(); + String producerGroup = message.getProducerGroup(); + + ProducerManager producerManager = eventMeshGrpcServer.getProducerManager(); + EventMeshProducer eventMeshProducer = producerManager.getEventMeshProducer(producerGroup); + + SendMessageContext sendMessageContext = new SendMessageContext(message.getSeqNum(), cloudEvent, eventMeshProducer, eventMeshGrpcServer); + + long startTime = System.currentTimeMillis(); + eventMeshProducer.send(sendMessageContext, new SendCallback() { + @Override + public void onSuccess(SendResult sendResult) { + ServiceUtils.sendResp(StatusCode.SUCCESS, sendResult.toString(), responseObserver); + long endTime = System.currentTimeMillis(); + logger.info("message|eventMesh2mq|REQ|ASYNC|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", + endTime - startTime, topic, seqNum, uniqueId); + } + + @Override + public void onException(OnExceptionContext context) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR, + EventMeshUtil.stackTrace(context.getException(), 2), responseObserver); + long endTime = System.currentTimeMillis(); + logger.error("message|eventMesh2mq|REQ|ASYNC|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", + endTime - startTime, topic, seqNum, uniqueId, context.getException()); + } + }); + + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java new file mode 100644 index 0000000000..0eee34ece4 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java @@ -0,0 +1,69 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.processor; + +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; +import java.util.List; + +public class SubscribeProcessor { + + private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + private EventMeshGrpcServer eventMeshGrpcServer; + + public SubscribeProcessor(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void process(Subscription subscription, StreamObserver responseObserver) throws Exception { + + RequestHeader header = subscription.getHeader(); + + if (!ServiceUtils.validateHeader(header)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + return; + } + + if (!ServiceUtils.validateSubscription(subscription)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + return; + } + + ConsumerManager consumerManager = eventMeshGrpcServer.getConsumerManager(); + + String consumerGroup = subscription.getConsumerGroup(); + String url = subscription.getUrl(); + List subscriptionItems = subscription.getSubscriptionItemsList(); + + for (Subscription.SubscriptionItem item : subscriptionItems) { + ConsumerGroupClient newClient = ConsumerGroupClient.builder() + .env(header.getEnv()) + .idc(header.getIdc()) + .sys(header.getSys()) + .ip(header.getIp()) + .pid(header.getPid()) + .consumerGroup(consumerGroup) + .topic(item.getTopic()) + .subscriptionMode(item.getMode()) + .url(url) + .lastUpTime(new Date()) + .build(); + + consumerManager.registerClient(newClient); + } + + consumerManager.restartEventMeshConsumer(consumerGroup); + + ServiceUtils.sendResp(StatusCode.SUCCESS, "subscribe success", responseObserver); + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/EventMeshProducer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/EventMeshProducer.java new file mode 100644 index 0000000000..c31a242e82 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/EventMeshProducer.java @@ -0,0 +1,118 @@ +/* + * Licensed 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.eventmesh.runtime.core.protocol.grpc.producer; + +import org.apache.eventmesh.api.RequestReplyCallback; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.apache.eventmesh.runtime.core.consumergroup.ProducerGroupConf; +import org.apache.eventmesh.runtime.core.plugin.MQProducerWrapper; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Properties; + +public class EventMeshProducer { + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + private ProducerGroupConf producerGroupConfig; + + private EventMeshGrpcConfiguration eventMeshGrpcConfiguration; + + private MQProducerWrapper mqProducerWrapper; + + private ServiceState serviceState; + + public void send(SendMessageContext sendMsgContext, SendCallback sendCallback) + throws Exception { + mqProducerWrapper.send(sendMsgContext.getEvent(), sendCallback); + } + + public void request(SendMessageContext sendMsgContext, RequestReplyCallback rrCallback, long timeout) + throws Exception { + mqProducerWrapper.request(sendMsgContext.getEvent(), rrCallback, timeout); + } + + public boolean reply(SendMessageContext sendMsgContext, SendCallback sendCallback) + throws Exception { + mqProducerWrapper.reply(sendMsgContext.getEvent(), sendCallback); + return true; + } + + public MQProducerWrapper getMqProducerWrapper() { + return mqProducerWrapper; + } + + public synchronized void init(EventMeshGrpcConfiguration eventMeshGrpcConfiguration, + ProducerGroupConf producerGroupConfig) throws Exception { + this.producerGroupConfig = producerGroupConfig; + this.eventMeshGrpcConfiguration = eventMeshGrpcConfiguration; + + Properties keyValue = new Properties(); + keyValue.put("producerGroup", producerGroupConfig.getGroupName()); + keyValue.put("instanceName", EventMeshUtil.buildMeshClientID( + producerGroupConfig.getGroupName(), eventMeshGrpcConfiguration.eventMeshCluster)); + + //TODO for defibus + keyValue.put("eventMeshIDC", eventMeshGrpcConfiguration.eventMeshIDC); + mqProducerWrapper = new MQProducerWrapper( + eventMeshGrpcConfiguration.eventMeshConnectorPluginType); + mqProducerWrapper.init(keyValue); + serviceState = ServiceState.INITED; + logger.info("EventMeshProducer [{}] inited...........", producerGroupConfig.getGroupName()); + } + + public synchronized void start() throws Exception { + if (serviceState == null || ServiceState.RUNNING.equals(serviceState)) { + return; + } + + mqProducerWrapper.start(); + serviceState = ServiceState.RUNNING; + logger.info("EventMeshProducer [{}] started..........", producerGroupConfig.getGroupName()); + } + + public synchronized void shutdown() throws Exception { + if (serviceState == null || ServiceState.INITED.equals(serviceState)) { + return; + } + + mqProducerWrapper.shutdown(); + serviceState = ServiceState.STOPED; + logger.info("EventMeshProducer [{}] shutdown.........", producerGroupConfig.getGroupName()); + } + + public ProducerGroupConf getProducerGroupConfig() { + return this.producerGroupConfig; + } + + public ServiceState getStatus() { + return this.serviceState; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("eventMeshProducer={").append("status=").append(serviceState.name()).append(",").append("producerGroupConfig=") + .append(producerGroupConfig).append("}"); + return sb.toString(); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/ProducerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/ProducerManager.java new file mode 100644 index 0000000000..60aade4bc9 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/ProducerManager.java @@ -0,0 +1,91 @@ +/* + * Licensed 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.eventmesh.runtime.core.protocol.grpc.producer; + +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.core.consumergroup.ProducerGroupConf; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.ConcurrentHashMap; + +public class ProducerManager { + + public Logger logger = LoggerFactory.getLogger(this.getClass()); + + private EventMeshGrpcServer eventMeshGrpcServer; + + private ConcurrentHashMap producerTable = new ConcurrentHashMap<>(); + + public ProducerManager(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void init() throws Exception { + logger.info("Grpc ProducerManager inited......"); + } + + public void start() throws Exception { + logger.info("Grpc ProducerManager started......"); + } + + public EventMeshProducer getEventMeshProducer(String producerGroup) throws Exception { + EventMeshProducer eventMeshProducer = null; + if (!producerTable.containsKey(producerGroup)) { + synchronized (producerTable) { + if (!producerTable.containsKey(producerGroup)) { + ProducerGroupConf producerGroupConfig = new ProducerGroupConf(producerGroup); + eventMeshProducer = createEventMeshProducer(producerGroupConfig); + eventMeshProducer.start(); + } + } + } + + eventMeshProducer = producerTable.get(producerGroup); + + if (!ServiceState.RUNNING.equals(eventMeshProducer.getStatus())) { + eventMeshProducer.start(); + } + + return eventMeshProducer; + } + + private synchronized EventMeshProducer createEventMeshProducer( + ProducerGroupConf producerGroupConfig) throws Exception { + if (producerTable.containsKey(producerGroupConfig.getGroupName())) { + return producerTable.get(producerGroupConfig.getGroupName()); + } + EventMeshProducer eventMeshProducer = new EventMeshProducer(); + eventMeshProducer.init(eventMeshGrpcServer.getEventMeshGrpcConfiguration(), + producerGroupConfig); + producerTable.put(producerGroupConfig.getGroupName(), eventMeshProducer); + return eventMeshProducer; + } + + public void shutdown() { + for (EventMeshProducer eventMeshProducer : producerTable.values()) { + try { + eventMeshProducer.shutdown(); + } catch (Exception ex) { + logger.error("shutdown eventMeshProducer[{}] err", eventMeshProducer, ex); + } + } + logger.info("producerManager shutdown......"); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/SendMessageContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/SendMessageContext.java new file mode 100644 index 0000000000..e0c28c5115 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/SendMessageContext.java @@ -0,0 +1,152 @@ +/* + * Licensed 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.eventmesh.runtime.core.protocol.grpc.producer; + +import io.cloudevents.CloudEvent; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.core.protocol.grpc.retry.RetryContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SendMessageContext extends RetryContext { + + public static Logger logger = LoggerFactory.getLogger("retry"); + + private CloudEvent event; + + private String bizSeqNo; + + private EventMeshProducer eventMeshProducer; + + private long createTime = System.currentTimeMillis(); + + private Map props; + + public EventMeshGrpcServer eventMeshGrpcServer; + + private List eventList; + + public SendMessageContext(String bizSeqNo, CloudEvent event, EventMeshProducer eventMeshProducer, + EventMeshGrpcServer eventMeshGrpcServer) { + this.bizSeqNo = bizSeqNo; + this.event = event; + this.eventMeshProducer = eventMeshProducer; + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void addProp(String key, String val) { + if (props == null) { + props = new HashMap<>(); + } + props.put(key, val); + } + + public String getProp(String key) { + return props.get(key); + } + + public String getBizSeqNo() { + return bizSeqNo; + } + + public void setBizSeqNo(String bizSeqNo) { + this.bizSeqNo = bizSeqNo; + } + + public CloudEvent getEvent() { + return event; + } + + public void setEvent(CloudEvent event) { + this.event = event; + } + + public EventMeshProducer getEventMeshProducer() { + return eventMeshProducer; + } + + public void setEventMeshProducer(EventMeshProducer eventMeshProducer) { + this.eventMeshProducer = eventMeshProducer; + } + + public long getCreateTime() { + return createTime; + } + + public void setCreateTime(long createTime) { + this.createTime = createTime; + } + + public List getEventList() { + return eventList; + } + + public void setEventList(List eventList) { + this.eventList = eventList; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("sendMessageContext={") + .append("bizSeqNo=").append(bizSeqNo) + .append(",retryTimes=").append(retryTimes) + .append(",producer=") + .append(eventMeshProducer != null ? eventMeshProducer : null) + .append(",executeTime=") + .append(DateFormatUtils.format(executeTime, Constants.DATE_FORMAT)) + .append(",createTime=") + .append(DateFormatUtils.format(createTime, Constants.DATE_FORMAT)).append("}"); + return sb.toString(); + } + + @Override + public boolean retry() throws Exception { + if (eventMeshProducer == null) { + return false; + } + + if (retryTimes > 0) { //retry once + return false; + } + + retryTimes++; + eventMeshProducer.send(this, new SendCallback() { + + @Override + public void onSuccess(SendResult sendResult) { + } + + @Override + public void onException(OnExceptionContext context) { + logger.warn("", context.getException()); + //eventMeshHTTPServer.metrics.summaryMetrics.recordSendBatchMsgFailed(1); + } + }); + return true; + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractHttpPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractHttpPushRequest.java new file mode 100644 index 0000000000..bcb3590707 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractHttpPushRequest.java @@ -0,0 +1,116 @@ +/* + * Licensed 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.eventmesh.runtime.core.protocol.grpc.push; + +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.HandleMsgContext; +import org.apache.eventmesh.runtime.core.protocol.grpc.retry.GrpcRetryer; +import org.apache.eventmesh.runtime.core.protocol.grpc.retry.RetryContext; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.RandomUtils; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + +public abstract class AbstractHttpPushRequest extends RetryContext { + + protected static HTTPClientPool httpClientPool = new HTTPClientPool(10); + protected EventMeshGrpcServer eventMeshGrpcServer; + protected long createTime = System.currentTimeMillis(); + protected long lastPushTime = System.currentTimeMillis(); + + /** **/ + protected Map> urls; + + protected volatile int startIdx; + protected EventMeshGrpcConfiguration eventMeshGrpcConfiguration; + protected GrpcRetryer retryer; + protected int ttl; + protected HandleMsgContext handleMsgContext; + private AtomicBoolean complete = new AtomicBoolean(Boolean.FALSE); + + private List totalUrls; + + public AbstractHttpPushRequest(HandleMsgContext handleMsgContext) { + this.eventMeshGrpcServer = handleMsgContext.getEventMeshGrpcServer(); + this.handleMsgContext = handleMsgContext; + this.urls = handleMsgContext.getConsumeTopicConfig().getIdcUrls(); + this.eventMeshGrpcConfiguration = handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration(); + this.retryer = handleMsgContext.getEventMeshGrpcServer().getGrpcRetryer(); + this.ttl = handleMsgContext.getTtl(); + + this.totalUrls = buildTotalUrls(); + this.startIdx = RandomUtils.nextInt(0, totalUrls.size()); + } + + public abstract void tryHttpRequest(); + + public void delayRetry() { + if (retryTimes < EventMeshConstants.DEFAULT_PUSH_RETRY_TIMES) { + retryTimes++; + delay(retryTimes * EventMeshConstants.DEFAULT_PUSH_RETRY_TIME_DISTANCE_IN_MILLSECONDS); + retryer.pushRetry(this); + } else { + complete.compareAndSet(Boolean.FALSE, Boolean.TRUE); + } + } + + public String getUrl() { + List localIdcUrl = MapUtils.getObject(urls, + eventMeshGrpcConfiguration.eventMeshIDC, null); + if (CollectionUtils.isNotEmpty(localIdcUrl)) { + return localIdcUrl.get((startIdx + retryTimes) % localIdcUrl.size()); + } + + if (CollectionUtils.isNotEmpty(totalUrls)) { + return totalUrls.get((startIdx + retryTimes) % totalUrls.size()); + } + + return null; + } + + private List buildTotalUrls() { + Set totalUrls = new HashSet<>(); + for (List idcUrls : urls.values()) { + totalUrls.addAll(idcUrls); + } + return new ArrayList<>(totalUrls); + } + + public boolean isComplete() { + return complete.get(); + } + + public void complete() { + complete.compareAndSet(Boolean.FALSE, Boolean.TRUE); + } + + public void timeout() { + if (!isComplete() && System.currentTimeMillis() - lastPushTime >= ttl) { + delayRetry(); + } + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java new file mode 100644 index 0000000000..2a4b39a81c --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java @@ -0,0 +1,305 @@ +/* + * Licensed 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.eventmesh.runtime.core.protocol.grpc.push; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.common.collect.Sets; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.exception.JsonException; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.http.HttpCommand; +import org.apache.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; +import org.apache.eventmesh.common.protocol.http.common.ClientRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.HandleMsgContext; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +public class AsyncHTTPPushRequest extends AbstractHttpPushRequest { + + public Logger messageLogger = LoggerFactory.getLogger("message"); + + public Logger cmdLogger = LoggerFactory.getLogger("cmd"); + + public Logger logger = LoggerFactory.getLogger(this.getClass()); + public String currPushUrl; + private Map> waitingRequests; + + public AsyncHTTPPushRequest(HandleMsgContext handleMsgContext, + Map> waitingRequests) { + super(handleMsgContext); + this.waitingRequests = waitingRequests; + } + + @Override + public void tryHttpRequest() { + + currPushUrl = getUrl(); + + if (StringUtils.isBlank(currPushUrl)) { + return; + } + + HttpPost builder = new HttpPost(currPushUrl); + + String requestCode = String.valueOf(RequestCode.HTTP_PUSH_CLIENT_ASYNC.getRequestCode()); + + builder.addHeader(ProtocolKey.REQUEST_CODE, requestCode); + builder.addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA); + builder.addHeader(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()); + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHCLUSTER, + handleMsgContext.getEventMeshGrpcServer() + .getEventMeshGrpcConfiguration().eventMeshCluster); + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIP, IPUtils.getLocalAddress()); + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHENV, + handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration().eventMeshEnv); + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIDC, + handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration().eventMeshIDC); + + CloudEvent event = CloudEventBuilder.from(handleMsgContext.getEvent()) + .withExtension(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, + String.valueOf(System.currentTimeMillis())) + .build(); + handleMsgContext.setEvent(event); + + String content = ""; + try { + String protocolType = Objects.requireNonNull(event.getExtension(Constants.PROTOCOL_TYPE)).toString(); + + ProtocolAdaptor protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + + ProtocolTransportObject protocolTransportObject = + protocolAdaptor.fromCloudEvent(handleMsgContext.getEvent()); + content = ((HttpCommand) protocolTransportObject).getBody().toMap().get("content").toString(); + } catch (Exception ex) { + return; + } + + List body = new ArrayList<>(); + body.add(new BasicNameValuePair(PushMessageRequestBody.CONTENT, content)); + if (StringUtils.isBlank(handleMsgContext.getBizSeqNo())) { + body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, + RandomStringUtils.generateNum(20))); + } else { + body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, + handleMsgContext.getBizSeqNo())); + } + if (StringUtils.isBlank(handleMsgContext.getUniqueId())) { + body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, + RandomStringUtils.generateNum(20))); + } else { + body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, + handleMsgContext.getUniqueId())); + } + + body.add(new BasicNameValuePair(PushMessageRequestBody.RANDOMNO, + handleMsgContext.getMsgRandomNo())); + body.add(new BasicNameValuePair(PushMessageRequestBody.TOPIC, handleMsgContext.getTopic())); + + body.add(new BasicNameValuePair(PushMessageRequestBody.EXTFIELDS, + JsonUtils.serialize(EventMeshUtil.getEventProp(handleMsgContext.getEvent())))); + + builder.setEntity(new UrlEncodedFormEntity(body, StandardCharsets.UTF_8)); + + //eventMeshHTTPServer.metrics.summaryMetrics.recordPushMsg(); + + this.lastPushTime = System.currentTimeMillis(); + + addToWaitingMap(this); + + cmdLogger.info("cmd={}|eventMesh2client|from={}|to={}", requestCode, + IPUtils.getLocalAddress(), currPushUrl); + + try { + httpClientPool.getClient().execute(builder, new ResponseHandler() { + @Override + public Object handleResponse(HttpResponse response) { + removeWaitingMap(AsyncHTTPPushRequest.this); + long cost = System.currentTimeMillis() - lastPushTime; + //eventMeshHTTPServer.metrics.summaryMetrics.recordHTTPPushTimeCost(cost); + if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { + //eventMeshHTTPServer.metrics.summaryMetrics.recordHttpPushMsgFailed(); + messageLogger.info( + "message|eventMesh2client|exception|url={}|topic={}|bizSeqNo={}" + + "|uniqueId={}|cost={}", currPushUrl, handleMsgContext.getTopic(), + handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), cost); + + delayRetry(); + if (isComplete()) { + handleMsgContext.finish(); + } + } else { + String res = ""; + try { + res = EntityUtils.toString(response.getEntity(), + Charset.forName(EventMeshConstants.DEFAULT_CHARSET)); + } catch (IOException e) { + handleMsgContext.finish(); + return new Object(); + } + ClientRetCode result = processResponseContent(res); + messageLogger.info( + "message|eventMesh2client|{}|url={}|topic={}|bizSeqNo={}" + + "|uniqueId={}|cost={}", + result, currPushUrl, handleMsgContext.getTopic(), + handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), cost); + if (result == ClientRetCode.OK) { + complete(); + if (isComplete()) { + handleMsgContext.finish(); + } + } else if (result == ClientRetCode.RETRY) { + delayRetry(); + if (isComplete()) { + handleMsgContext.finish(); + } + } else if (result == ClientRetCode.NOLISTEN) { + delayRetry(); + if (isComplete()) { + handleMsgContext.finish(); + } + } else if (result == ClientRetCode.FAIL) { + complete(); + if (isComplete()) { + handleMsgContext.finish(); + } + } + } + return new Object(); + } + }); + + if (messageLogger.isDebugEnabled()) { + messageLogger.debug("message|eventMesh2client|url={}|topic={}|event={}", currPushUrl, + handleMsgContext.getTopic(), + handleMsgContext.getEvent()); + } else { + messageLogger + .info("message|eventMesh2client|url={}|topic={}|bizSeqNo={}|uniqueId={}", + currPushUrl, handleMsgContext.getTopic(), + handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId()); + } + } catch (IOException e) { + messageLogger.error("push2client err", e); + removeWaitingMap(this); + delayRetry(); + if (isComplete()) { + handleMsgContext.finish(); + } + } + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("asyncPushRequest={") + .append("bizSeqNo=").append(handleMsgContext.getBizSeqNo()) + .append(",startIdx=").append(startIdx) + .append(",retryTimes=").append(retryTimes) + .append(",uniqueId=").append(handleMsgContext.getUniqueId()) + .append(",executeTime=") + .append(DateFormatUtils.format(executeTime, Constants.DATE_FORMAT)) + .append(",lastPushTime=") + .append(DateFormatUtils.format(lastPushTime, Constants.DATE_FORMAT)) + .append(",createTime=") + .append(DateFormatUtils.format(createTime, Constants.DATE_FORMAT)).append("}"); + return sb.toString(); + } + + ClientRetCode processResponseContent(String content) { + if (StringUtils.isBlank(content)) { + return ClientRetCode.FAIL; + } + + try { + Map ret = + JsonUtils.deserialize(content, new TypeReference>() { + }); + Integer retCode = (Integer) ret.get("retCode"); + if (retCode != null && ClientRetCode.contains(retCode)) { + return ClientRetCode.get(retCode); + } + + return ClientRetCode.FAIL; + } catch (NumberFormatException e) { + messageLogger.warn("url:{}, bizSeqno:{}, uniqueId:{}, httpResponse:{}", currPushUrl, + handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), content); + return ClientRetCode.FAIL; + } catch (JsonException e) { + messageLogger.warn("url:{}, bizSeqno:{}, uniqueId:{}, httpResponse:{}", currPushUrl, + handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), content); + return ClientRetCode.FAIL; + } catch (Throwable t) { + messageLogger.warn("url:{}, bizSeqno:{}, uniqueId:{}, httpResponse:{}", currPushUrl, + handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), content); + return ClientRetCode.FAIL; + } + } + + private void addToWaitingMap(AsyncHTTPPushRequest request) { + if (waitingRequests.containsKey(request.handleMsgContext.getConsumerGroup())) { + waitingRequests.get(request.handleMsgContext.getConsumerGroup()).add(request); + return; + } + waitingRequests + .put(request.handleMsgContext.getConsumerGroup(), Sets.newConcurrentHashSet()); + waitingRequests.get(request.handleMsgContext.getConsumerGroup()).add(request); + } + + private void removeWaitingMap(AsyncHTTPPushRequest request) { + if (waitingRequests.containsKey(request.handleMsgContext.getConsumerGroup())) { + waitingRequests.get(request.handleMsgContext.getConsumerGroup()).remove(request); + } + } + + @Override + public boolean retry() { + tryHttpRequest(); + return true; + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPClientPool.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPClientPool.java new file mode 100644 index 0000000000..7cfba65c3b --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPClientPool.java @@ -0,0 +1,57 @@ +/* + * Licensed 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.eventmesh.runtime.core.protocol.grpc.push; + +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.RandomUtils; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; + +import java.util.Iterator; +import java.util.List; + +public class HTTPClientPool { + + private List clients = Lists.newArrayList(); + + private int core = 1; + + public HTTPClientPool(int core) { + this.core = core; + } + + public CloseableHttpClient getClient() { + if (CollectionUtils.size(clients) < core) { + CloseableHttpClient client = HttpClients.createDefault(); + clients.add(client); + return client; + } + return clients.get(RandomUtils.nextInt(core, 2 * core) % core); + } + + + public void shutdown() throws Exception { + Iterator itr = clients.iterator(); + while (itr.hasNext()) { + CloseableHttpClient client = itr.next(); + client.close(); + itr.remove(); + } + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPMessageHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPMessageHandler.java new file mode 100644 index 0000000000..3e961ed7d7 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPMessageHandler.java @@ -0,0 +1,85 @@ +/* + * Licensed 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.eventmesh.runtime.core.protocol.grpc.push; + +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.apache.commons.collections4.MapUtils; +import org.apache.eventmesh.common.ThreadPoolFactory; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.MessageHandler; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.HandleMsgContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +public class HTTPMessageHandler implements MessageHandler { + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + private static final ScheduledExecutorService SCHEDULER = ThreadPoolFactory.createSingleScheduledExecutor("eventMesh-pushMsgTimeout-"); + + private ThreadPoolExecutor pushExecutor; + + private final Integer CONSUMER_GROUP_WAITING_REQUEST_THRESHOLD = 10000; + + private static Map> waitingRequests = Maps.newConcurrentMap(); + + public HTTPMessageHandler(String consumerGroup, ThreadPoolExecutor pushMsgExecutor) { + this.pushExecutor = pushMsgExecutor; + waitingRequests.put(consumerGroup, Sets.newConcurrentHashSet()); + SCHEDULER.scheduleAtFixedRate(this::checkTimeout, 0, 1000, TimeUnit.MILLISECONDS); + } + + private void checkTimeout() { + waitingRequests.entrySet().stream().forEach(entry -> { + for (AbstractHttpPushRequest request : entry.getValue()) { + request.timeout(); + waitingRequests.get(request.handleMsgContext.getConsumerGroup()).remove(request); + } + }); + } + + @Override + public boolean handle(final HandleMsgContext handleMsgContext) { + Set waitingRequests4Group = MapUtils.getObject(waitingRequests, + handleMsgContext.getConsumerGroup(), Sets.newConcurrentHashSet()); + if (waitingRequests4Group.size() > CONSUMER_GROUP_WAITING_REQUEST_THRESHOLD) { + logger.warn("waitingRequests is too many, so reject, this message will be send back to MQ, consumerGroup:{}, threshold:{}", + handleMsgContext.getConsumerGroup(), CONSUMER_GROUP_WAITING_REQUEST_THRESHOLD); + return false; + } + + try { + pushExecutor.submit(() -> { + AsyncHTTPPushRequest asyncPushRequest = new AsyncHTTPPushRequest(handleMsgContext, waitingRequests); + asyncPushRequest.tryHttpRequest(); + }); + return true; + } catch (RejectedExecutionException e) { + //logger.warn("pushMsgThreadPoolQueue is full, so reject, current task size {}", + //handleMsgContext.getEventMeshHTTPServer().getPushMsgExecutor().getQueue().size(), e); + return false; + } + } +} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/request/SubjectCreateRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/DelayRetryable.java similarity index 81% rename from eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/request/SubjectCreateRequest.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/DelayRetryable.java index e25689aaa9..bba736d1de 100644 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/request/SubjectCreateRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/DelayRetryable.java @@ -14,12 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.eventmesh.schema.registry.server.request; -import lombok.AllArgsConstructor; -import lombok.Data; +package org.apache.eventmesh.runtime.core.protocol.grpc.retry; -@Data -@AllArgsConstructor -public class SubjectCreateRequest { +import java.util.concurrent.Delayed; + +public interface DelayRetryable extends Delayed { + boolean retry() throws Exception; } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/GrpcRetryer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/GrpcRetryer.java new file mode 100644 index 0000000000..be9001da21 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/GrpcRetryer.java @@ -0,0 +1,122 @@ +/* + * Licensed 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.eventmesh.runtime.core.protocol.grpc.retry; + +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.DelayQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +public class GrpcRetryer { + + private Logger retryLogger = LoggerFactory.getLogger("retry"); + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + private EventMeshGrpcServer eventMeshGrpcServer; + + private EventMeshGrpcConfiguration grpcConfiguration; + + public GrpcRetryer(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + this.grpcConfiguration = eventMeshGrpcServer.getEventMeshGrpcConfiguration(); + } + + private DelayQueue failed = new DelayQueue(); + + private ThreadPoolExecutor pool; + + private Thread dispatcher; + + public void pushRetry(DelayRetryable delayRetryable) { + if (failed.size() >= eventMeshGrpcServer.getEventMeshGrpcConfiguration() + .eventMeshServerRetryBlockQSize) { + retryLogger.error("[RETRY-QUEUE] is full!"); + return; + } + failed.offer(delayRetryable); + } + + public void init() { + pool = new ThreadPoolExecutor(grpcConfiguration.eventMeshServerRetryThreadNum, + grpcConfiguration.eventMeshServerRetryThreadNum, + 60000, + TimeUnit.MILLISECONDS, + new ArrayBlockingQueue(grpcConfiguration.eventMeshServerRetryBlockQSize), + new ThreadFactory() { + private AtomicInteger count = new AtomicInteger(); + + @Override + public Thread newThread(Runnable r) { + Thread thread = new Thread(r, "grpc-retry-" + count.incrementAndGet()); + thread.setPriority(Thread.NORM_PRIORITY); + thread.setDaemon(true); + return thread; + } + }, new ThreadPoolExecutor.AbortPolicy()); + + dispatcher = new Thread(new Runnable() { + @Override + public void run() { + try { + DelayRetryable retryObj = null; + while (!Thread.currentThread().isInterrupted() + && (retryObj = failed.take()) != null) { + final DelayRetryable delayRetryable = retryObj; + pool.execute(() -> { + try { + delayRetryable.retry(); + if (retryLogger.isDebugEnabled()) { + retryLogger.debug("retryObj : {}", delayRetryable); + } + } catch (Exception e) { + retryLogger.error("grpc-retry-dispatcher error!", e); + } + }); + } + } catch (Exception e) { + retryLogger.error("grpc-retry-dispatcher error!", e); + } + } + }, "grpc-retry-dispatcher"); + dispatcher.setDaemon(true); + logger.info("GrpcRetryer inited......"); + } + + public int size() { + return failed.size(); + } + + public void shutdown() { + dispatcher.interrupt(); + pool.shutdown(); + logger.info("GrpcRetryer shutdown......"); + } + + public void start() throws Exception { + dispatcher.start(); + logger.info("GrpcRetryer started......"); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/RetryContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/RetryContext.java new file mode 100644 index 0000000000..c09f3b9f54 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/RetryContext.java @@ -0,0 +1,50 @@ +/* + * Licensed 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.eventmesh.runtime.core.protocol.grpc.retry; + +import java.util.concurrent.Delayed; +import java.util.concurrent.TimeUnit; + +public abstract class RetryContext implements DelayRetryable { + + public int retryTimes = 0; + + public long executeTime = System.currentTimeMillis(); + + public RetryContext delay(long delay) { + this.executeTime = System.currentTimeMillis() + delay; + return this; + } + + @Override + public int compareTo(Delayed delayed) { + RetryContext obj = (RetryContext) delayed; + if (this.executeTime > obj.executeTime) { + return 1; + } else if (this.executeTime == obj.executeTime) { + return 0; + } else { + return -1; + } + } + + @Override + public long getDelay(TimeUnit unit) { + return unit.convert(this.executeTime - System.currentTimeMillis(), TimeUnit.MILLISECONDS); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java new file mode 100644 index 0000000000..312a4dc503 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java @@ -0,0 +1,43 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.service; + +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.ConsumerServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SubscribeProcessor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.ThreadPoolExecutor; + +public class ConsumerService extends ConsumerServiceGrpc.ConsumerServiceImplBase { + + private Logger logger = LoggerFactory.getLogger(ProducerService.class); + + private EventMeshGrpcServer eventMeshGrpcServer; + + private ThreadPoolExecutor threadPoolExecutor; + + public ConsumerService(EventMeshGrpcServer eventMeshGrpcServer, + ThreadPoolExecutor threadPoolExecutor) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + this.threadPoolExecutor = threadPoolExecutor; + } + + public void subscribe(Subscription request, StreamObserver responseObserver) { + threadPoolExecutor.submit(() -> { + SubscribeProcessor subscribeProcessor = new SubscribeProcessor(eventMeshGrpcServer); + try { + subscribeProcessor.process(request, responseObserver); + } catch (Exception e) { + logger.error("Error code {}, error message {}", EventMeshRetCode.EVENTMESH_SUBSCRIBE_ERR.getRetCode(), + StatusCode.EVENTMESH_SUBSCRIBE_ERR.getErrMsg(), e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_SUBSCRIBE_ERR, e.getMessage(), + responseObserver); + } + }); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java new file mode 100644 index 0000000000..edd2d17e74 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java @@ -0,0 +1,44 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.service; + +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SendAsyncMessageProcessor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.ThreadPoolExecutor; + +public class ProducerService extends PublisherServiceGrpc.PublisherServiceImplBase { + + private Logger logger = LoggerFactory.getLogger(ProducerService.class); + + private EventMeshGrpcServer eventMeshGrpcServer; + + private ThreadPoolExecutor threadPoolExecutor; + + public ProducerService(EventMeshGrpcServer eventMeshGrpcServer, + ThreadPoolExecutor threadPoolExecutor) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + this.threadPoolExecutor = threadPoolExecutor; + } + + public void publish(EventMeshMessage request, StreamObserver responseObserver) { + threadPoolExecutor.submit(() -> { + SendAsyncMessageProcessor sendAsyncMessageProcessor = new SendAsyncMessageProcessor(eventMeshGrpcServer); + try { + sendAsyncMessageProcessor.process(request, responseObserver); + } catch (Exception e) { + logger.error("Error code {}, error message {}", EventMeshRetCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getRetCode(), + StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getErrMsg(), e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR, e.getMessage(), + responseObserver); + } + }); + } + +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java new file mode 100644 index 0000000000..5a03286e37 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java @@ -0,0 +1,59 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.service; + +import io.grpc.stub.StreamObserver; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; + +public class ServiceUtils { + + public static boolean validateHeader(RequestHeader header) { + return !StringUtils.isBlank(header.getIdc()) + && !StringUtils.isBlank(header.getPid()) + && StringUtils.isNumeric(header.getPid()) + && !StringUtils.isBlank(header.getSys()); + } + + public static boolean validateMessage(EventMeshMessage message) { + return !StringUtils.isBlank(message.getUniqueId()) + && !StringUtils.isBlank(message.getProducerGroup()) + && !StringUtils.isBlank(message.getTopic()) + && !StringUtils.isBlank(message.getContent()) + && (!StringUtils.isBlank(message.getTtl())); + } + + public static boolean validateSubscription(Subscription subscription) { + if (CollectionUtils.isEmpty(subscription.getSubscriptionItemsList()) + || StringUtils.isBlank(subscription.getConsumerGroup())) { + return false; + } + for (Subscription.SubscriptionItem item : subscription.getSubscriptionItemsList()) { + if (StringUtils.isBlank(item.getTopic()) + || item.getMode() == Subscription.SubscriptionItem.SubscriptionMode.UNRECOGNIZED + || item.getType() == Subscription.SubscriptionItem.SubscriptionType.UNRECOGNIZED) { + return false; + } + } + return true; + } + + public static void sendResp(StatusCode code, StreamObserver responseObserver) { + Response response = Response.newBuilder() + .setRespCode(code.getRetCode()) + .setRespMsg(code.getErrMsg()).build(); + responseObserver.onNext(response); + responseObserver.onCompleted(); + } + + public static void sendResp(StatusCode code, String message, StreamObserver responseObserver) { + Response response = Response.newBuilder() + .setRespCode(code.getRetCode()) + .setRespMsg(code.getErrMsg() + " " + message).build(); + responseObserver.onNext(response); + responseObserver.onCompleted(); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/EventMeshConsumer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/EventMeshConsumer.java index ef051b03f4..fd4a704f1d 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/EventMeshConsumer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/EventMeshConsumer.java @@ -21,17 +21,12 @@ import java.util.Properties; import java.util.concurrent.atomic.AtomicBoolean; -import io.openmessaging.api.AsyncConsumeContext; -import io.openmessaging.api.AsyncMessageListener; -import io.openmessaging.api.Message; -import io.openmessaging.api.OnExceptionContext; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; import org.apache.commons.collections4.MapUtils; -import org.apache.eventmesh.api.AbstractContext; -import org.apache.eventmesh.api.EventMeshAction; -import org.apache.eventmesh.api.EventMeshAsyncConsumeContext; +import org.apache.eventmesh.api.*; +import org.apache.eventmesh.api.exception.OnExceptionContext; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.SubscriptionItem; import org.apache.eventmesh.common.protocol.SubscriptionMode; @@ -110,18 +105,22 @@ public synchronized void start() throws Exception { } public void subscribe(String topic, SubscriptionItem subscriptionItem) throws Exception { - AsyncMessageListener listener = null; + EventListener listener = null; if (!SubscriptionMode.BROADCASTING.equals(subscriptionItem.getMode())) { - listener = new AsyncMessageListener() { + listener = new EventListener() { @Override - public void consume(Message message, AsyncConsumeContext context) { - String topic = message.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION); - String bizSeqNo = message.getSystemProperties(Constants.PROPERTY_MESSAGE_SEARCH_KEYS); - String uniqueId = message.getUserProperties(Constants.RMB_UNIQ_ID); - - message.getUserProperties().put(EventMeshConstants.REQ_MQ2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())); + public void consume(CloudEvent event, AsyncConsumeContext context) { + String topic = event.getSubject(); +// String topic = message.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION); + String bizSeqNo = (String) event.getExtension(Constants.PROPERTY_MESSAGE_SEARCH_KEYS); + String uniqueId = (String) event.getExtension(Constants.RMB_UNIQ_ID); + + event = CloudEventBuilder.from(event) + .withExtension(EventMeshConstants.REQ_MQ2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .build(); +// message.getUserProperties().put(EventMeshConstants.REQ_MQ2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())); if (messageLogger.isDebugEnabled()) { - messageLogger.debug("message|mq2eventMesh|topic={}|msg={}", topic, message); + messageLogger.debug("message|mq2eventMesh|topic={}|event={}", topic, event); } else { messageLogger.info("message|mq2eventMesh|topic={}|bizSeqNo={}|uniqueId={}", topic, bizSeqNo, uniqueId); } @@ -132,7 +131,7 @@ public void consume(Message message, AsyncConsumeContext context) { if (currentTopicConfig == null) { logger.error("no topicConfig found, consumerGroup:{} topic:{}", consumerGroupConf.getConsumerGroup(), topic); try { - sendMessageBack(message, uniqueId, bizSeqNo); + sendMessageBack(event, uniqueId, bizSeqNo); // context.attributes().put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS.name()); // context.ack(); eventMeshAsyncConsumeContext.commit(EventMeshAction.CommitMessage); @@ -141,7 +140,7 @@ public void consume(Message message, AsyncConsumeContext context) { } } HandleMsgContext handleMsgContext = new HandleMsgContext(EventMeshUtil.buildPushMsgSeqNo(), consumerGroupConf.getConsumerGroup(), EventMeshConsumer.this, - topic, message, subscriptionItem, eventMeshAsyncConsumeContext.getAbstractContext(), consumerGroupConf, eventMeshHTTPServer, bizSeqNo, uniqueId, currentTopicConfig); + topic, event, subscriptionItem, eventMeshAsyncConsumeContext.getAbstractContext(), consumerGroupConf, eventMeshHTTPServer, bizSeqNo, uniqueId, currentTopicConfig); if (httpMessageHandler.handle(handleMsgContext)) { // context.attributes().put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.CONSUME_FINISH.name()); @@ -149,7 +148,7 @@ public void consume(Message message, AsyncConsumeContext context) { eventMeshAsyncConsumeContext.commit(EventMeshAction.ManualAck); } else { try { - sendMessageBack(message, uniqueId, bizSeqNo); + sendMessageBack(event, uniqueId, bizSeqNo); } catch (Exception e) { } @@ -161,17 +160,20 @@ public void consume(Message message, AsyncConsumeContext context) { }; persistentMqConsumer.subscribe(topic, listener); } else { - listener = new AsyncMessageListener() { + listener = new EventListener() { @Override - public void consume(Message message, AsyncConsumeContext context) { - String topic = message.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION); - String bizSeqNo = message.getSystemProperties(Constants.PROPERTY_MESSAGE_SEARCH_KEYS); - String uniqueId = message.getUserProperties(Constants.RMB_UNIQ_ID); + public void consume(CloudEvent event, AsyncConsumeContext context) { + + event = CloudEventBuilder.from(event) + .withExtension(EventMeshConstants.REQ_MQ2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .build(); - message.getUserProperties().put(EventMeshConstants.REQ_MQ2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())); + String topic = event.getSubject(); + String bizSeqNo = event.getExtension(Constants.PROPERTY_MESSAGE_SEARCH_KEYS).toString(); + String uniqueId = event.getExtension(Constants.RMB_UNIQ_ID).toString(); if (messageLogger.isDebugEnabled()) { - messageLogger.debug("message|mq2eventMesh|topic={}|msg={}", topic, message); + messageLogger.debug("message|mq2eventMesh|topic={}|msg={}", topic, event); } else { messageLogger.info("message|mq2eventMesh|topic={}|bizSeqNo={}|uniqueId={}", topic, bizSeqNo, uniqueId); } @@ -182,7 +184,7 @@ public void consume(Message message, AsyncConsumeContext context) { if (currentTopicConfig == null) { logger.error("no topicConfig found, consumerGroup:{} topic:{}", consumerGroupConf.getConsumerGroup(), topic); try { - sendMessageBack(message, uniqueId, bizSeqNo); + sendMessageBack(event, uniqueId, bizSeqNo); // context.attributes().put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS.name()); // context.ack(); eventMeshAsyncConsumeContext.commit(EventMeshAction.CommitMessage); @@ -191,7 +193,7 @@ public void consume(Message message, AsyncConsumeContext context) { } } HandleMsgContext handleMsgContext = new HandleMsgContext(EventMeshUtil.buildPushMsgSeqNo(), consumerGroupConf.getConsumerGroup(), EventMeshConsumer.this, - topic, message, subscriptionItem, eventMeshAsyncConsumeContext.getAbstractContext(), consumerGroupConf, eventMeshHTTPServer, bizSeqNo, uniqueId, currentTopicConfig); + topic, event, subscriptionItem, eventMeshAsyncConsumeContext.getAbstractContext(), consumerGroupConf, eventMeshHTTPServer, bizSeqNo, uniqueId, currentTopicConfig); if (httpMessageHandler.handle(handleMsgContext)) { // context.attributes().put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.CONSUME_FINISH.name()); @@ -199,7 +201,7 @@ public void consume(Message message, AsyncConsumeContext context) { eventMeshAsyncConsumeContext.commit(EventMeshAction.ManualAck); } else { try { - sendMessageBack(message, uniqueId, bizSeqNo); + sendMessageBack(event, uniqueId, bizSeqNo); } catch (Exception e) { } @@ -237,11 +239,11 @@ public synchronized void shutdown() throws Exception { started4Broadcast.compareAndSet(true, false); } - public void updateOffset(String topic, SubscriptionMode subscriptionMode, List msgs, AbstractContext context) { + public void updateOffset(String topic, SubscriptionMode subscriptionMode, List events, AbstractContext context) { if (SubscriptionMode.BROADCASTING.equals(subscriptionMode)) { - broadcastMqConsumer.updateOffset(msgs, context); + broadcastMqConsumer.updateOffset(events, context); } else { - persistentMqConsumer.updateOffset(msgs, context); + persistentMqConsumer.updateOffset(events, context); } } @@ -253,7 +255,7 @@ public EventMeshHTTPServer getEventMeshHTTPServer() { return eventMeshHTTPServer; } - public void sendMessageBack(final Message msgBack, final String uniqueId, String bizSeqNo) throws Exception { + public void sendMessageBack(final CloudEvent event, final String uniqueId, String bizSeqNo) throws Exception { EventMeshProducer sendMessageBack = eventMeshHTTPServer.getProducerManager().getEventMeshProducer(consumerGroupConf.getConsumerGroup()); @@ -263,7 +265,7 @@ public void sendMessageBack(final Message msgBack, final String uniqueId, String return; } - final SendMessageContext sendMessageBackContext = new SendMessageContext(bizSeqNo, msgBack, sendMessageBack, eventMeshHTTPServer); + final SendMessageContext sendMessageBackContext = new SendMessageContext(bizSeqNo, event, sendMessageBack, eventMeshHTTPServer); sendMessageBack.send(sendMessageBackContext, new SendCallback() { @Override diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/HandleMsgContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/HandleMsgContext.java index 3ce124c408..711a6dd030 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/HandleMsgContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/HandleMsgContext.java @@ -21,8 +21,7 @@ import java.util.HashMap; import java.util.Map; -import io.openmessaging.api.Message; - +import io.cloudevents.CloudEvent; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.eventmesh.api.AbstractContext; @@ -53,7 +52,7 @@ public class HandleMsgContext { private SubscriptionItem subscriptionItem; - private Message msg; + private CloudEvent event; private int ttl; @@ -70,14 +69,14 @@ public class HandleMsgContext { private Map props; public HandleMsgContext(String msgRandomNo, String consumerGroup, EventMeshConsumer eventMeshConsumer, - String topic, Message msg, SubscriptionItem subscriptionItem, + String topic, CloudEvent event, SubscriptionItem subscriptionItem, AbstractContext context, ConsumerGroupConf consumerGroupConfig, EventMeshHTTPServer eventMeshHTTPServer, String bizSeqNo, String uniqueId, ConsumerGroupTopicConf consumeTopicConfig) { this.msgRandomNo = msgRandomNo; this.consumerGroup = consumerGroup; this.eventMeshConsumer = eventMeshConsumer; this.topic = topic; - this.msg = msg; + this.event = event; this.subscriptionItem = subscriptionItem; this.context = context; this.consumerGroupConfig = consumerGroupConfig; @@ -85,7 +84,8 @@ public HandleMsgContext(String msgRandomNo, String consumerGroup, EventMeshConsu this.bizSeqNo = bizSeqNo; this.uniqueId = uniqueId; this.consumeTopicConfig = consumeTopicConfig; - String ttlStr = msg.getUserProperties(Constants.PROPERTY_MESSAGE_TIMEOUT); + + String ttlStr = (String) event.getExtension(Constants.PROPERTY_MESSAGE_TIMEOUT); this.ttl = StringUtils.isNumeric(ttlStr)? Integer.parseInt(ttlStr): EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS; } @@ -148,12 +148,12 @@ public void setTopic(String topic) { this.topic = topic; } - public Message getMsg() { - return msg; + public CloudEvent getEvent() { + return event; } - public void setMsg(Message msg) { - this.msg = msg; + public void setEvent(CloudEvent event) { + this.event = event; } public SubscriptionItem getSubscriptionItem() { @@ -193,14 +193,14 @@ public EventMeshHTTPServer getEventMeshHTTPServer() { } public void finish() { - if (eventMeshConsumer != null && context != null && msg != null) { + if (eventMeshConsumer != null && context != null && event != null) { if (messageLogger.isDebugEnabled()) { // messageLogger.debug("messageAcked|topic={}|msgId={}|cluster={}|broker={}|queueId={}|queueOffset={}", topic, // msg.getMsgId(), msg.getProperty(DeFiBusConstant.PROPERTY_MESSAGE_CLUSTER), // msg.getProperty(DeFiBusConstant.PROPERTY_MESSAGE_BROKER), // msg.getQueueId(), msg.getQueueOffset()); } - eventMeshConsumer.updateOffset(topic, subscriptionItem.getMode(), Arrays.asList(msg), context); + eventMeshConsumer.updateOffset(topic, subscriptionItem.getMode(), Arrays.asList(event), context); } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminMetricsProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminMetricsProcessor.java index dac27461b8..a8153c60a6 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminMetricsProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminMetricsProcessor.java @@ -19,7 +19,7 @@ import io.netty.channel.ChannelHandlerContext; -import org.apache.eventmesh.common.command.HttpCommand; +import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; import org.apache.eventmesh.runtime.core.protocol.http.async.AsyncContext; import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; @@ -28,8 +28,6 @@ public class AdminMetricsProcessor implements HttpRequestProcessor { - public Logger cmdLogger = LoggerFactory.getLogger("cmd"); - private EventMeshHTTPServer eventMeshHTTPServer; public AdminMetricsProcessor(EventMeshHTTPServer eventMeshHTTPServer) { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminShutdownProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminShutdownProcessor.java index 775a7c1730..97db4bba44 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminShutdownProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminShutdownProcessor.java @@ -17,10 +17,8 @@ package org.apache.eventmesh.runtime.core.protocol.http.processor; -import io.netty.channel.ChannelHandlerContext; - -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.command.HttpCommand; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; import org.apache.eventmesh.common.protocol.http.common.RequestCode; import org.apache.eventmesh.runtime.boot.EventMeshServer; @@ -28,9 +26,12 @@ import org.apache.eventmesh.runtime.core.protocol.http.async.AsyncContext; import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; import org.apache.eventmesh.runtime.util.RemotingHelper; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.netty.channel.ChannelHandlerContext; + public class AdminShutdownProcessor implements HttpRequestProcessor { public Logger cmdLogger = LoggerFactory.getLogger("cmd"); @@ -45,14 +46,14 @@ public AdminShutdownProcessor(EventMeshServer eventMeshServer) { public void processRequest(ChannelHandlerContext ctx, AsyncContext asyncContext) throws Exception { HttpCommand responseEventMeshCommand; - cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", RequestCode.get(Integer.valueOf(asyncContext.getRequest().getRequestCode())), - EventMeshConstants.PROTOCOL_HTTP, - RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtil.getLocalAddress()); + cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", + RequestCode.get(Integer.valueOf(asyncContext.getRequest().getRequestCode())), + EventMeshConstants.PROTOCOL_HTTP, + RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtils.getLocalAddress()); eventMeshServer.shutdown(); - responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - EventMeshRetCode.SUCCESS.getRetCode(), EventMeshRetCode.SUCCESS.getErrMsg()); + responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse(EventMeshRetCode.SUCCESS); asyncContext.onComplete(responseEventMeshCommand); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageProcessor.java index a8b7197816..24e6119f63 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageProcessor.java @@ -17,23 +17,29 @@ package org.apache.eventmesh.runtime.core.protocol.http.processor; +import io.cloudevents.CloudEvent; +import io.cloudevents.CloudEventData; +import io.cloudevents.core.builder.CloudEventBuilder; import io.netty.channel.ChannelHandlerContext; -import io.openmessaging.api.Message; -import io.openmessaging.api.OnExceptionContext; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.command.HttpCommand; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchRequestBody; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchResponseBody; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; import org.apache.eventmesh.common.protocol.http.common.RequestCode; import org.apache.eventmesh.common.protocol.http.header.message.SendMessageBatchRequestHeader; import org.apache.eventmesh.common.protocol.http.header.message.SendMessageBatchResponseHeader; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.acl.Acl; import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; import org.apache.eventmesh.runtime.constants.EventMeshConstants; @@ -48,6 +54,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -72,30 +79,20 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", RequestCode.get(Integer.valueOf(asyncContext.getRequest().getRequestCode())), EventMeshConstants.PROTOCOL_HTTP, - RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtil.getLocalAddress()); + RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtils.getLocalAddress()); SendMessageBatchRequestHeader sendMessageBatchRequestHeader = (SendMessageBatchRequestHeader) asyncContext.getRequest().getHeader(); - SendMessageBatchRequestBody sendMessageBatchRequestBody = (SendMessageBatchRequestBody) asyncContext.getRequest().getBody(); SendMessageBatchResponseHeader sendMessageBatchResponseHeader = SendMessageBatchResponseHeader.buildHeader(Integer.valueOf(asyncContext.getRequest().getRequestCode()), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshCluster, - IPUtil.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, + IPUtils.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshIDC); - if (StringUtils.isBlank(sendMessageBatchRequestHeader.getPid()) - || !StringUtils.isNumeric(sendMessageBatchRequestHeader.getPid()) - || StringUtils.isBlank(sendMessageBatchRequestHeader.getSys())) { - responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - sendMessageBatchResponseHeader, - SendMessageBatchResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); - asyncContext.onComplete(responseEventMeshCommand); - return; - } + String protocolType = sendMessageBatchRequestHeader.getProtocolType(); + ProtocolAdaptor httpCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + List eventList = httpCommandProtocolAdaptor.toBatchCloudEvent(asyncContext.getRequest()); - if (CollectionUtils.isEmpty(sendMessageBatchRequestBody.getContents()) - || StringUtils.isBlank(sendMessageBatchRequestBody.getBatchId()) - || StringUtils.isBlank(sendMessageBatchRequestBody.getProducerGroup()) - || (Integer.valueOf(sendMessageBatchRequestBody.getSize()) != CollectionUtils.size(sendMessageBatchRequestBody.getContents()))) { + if (CollectionUtils.isEmpty(eventList)) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( sendMessageBatchResponseHeader, SendMessageBatchResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getErrMsg())); @@ -103,19 +100,70 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext return; } + String batchId = ""; + String producerGroup = ""; + int eventSize = eventList.size(); + + for (CloudEvent event : eventList) { + //validate event + if (StringUtils.isBlank(event.getId()) + || event.getSource() == null + || event.getSpecVersion() == null + || StringUtils.isBlank(event.getType()) + || StringUtils.isBlank(event.getSubject())) { + responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( + sendMessageBatchResponseHeader, + SendMessageBatchResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); + asyncContext.onComplete(responseEventMeshCommand); + return; + } + + String idc = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.IDC)).toString(); + String pid = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.PID)).toString(); + String sys = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.SYS)).toString(); + + //validate event-extension + if (StringUtils.isBlank(idc) + || StringUtils.isBlank(pid) + || !StringUtils.isNumeric(pid) + || StringUtils.isBlank(sys)) { + responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( + sendMessageBatchResponseHeader, + SendMessageBatchResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); + asyncContext.onComplete(responseEventMeshCommand); + return; + } + + + batchId = Objects.requireNonNull(event.getExtension(SendMessageBatchRequestBody.BATCHID)).toString(); + producerGroup = Objects.requireNonNull(event.getExtension(SendMessageBatchRequestBody.PRODUCERGROUP)).toString(); + String topic = event.getSubject(); + eventSize = Integer.parseInt(Objects.requireNonNull(event.getExtension(SendMessageBatchRequestBody.SIZE)).toString()); + CloudEventData eventData = event.getData(); + + if (eventData != null || StringUtils.isBlank(batchId) + || StringUtils.isBlank(producerGroup) + || eventSize != eventList.size()) { + responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( + sendMessageBatchResponseHeader, + SendMessageBatchResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getErrMsg())); + asyncContext.onComplete(responseEventMeshCommand); + return; + } + + } + if (!eventMeshHTTPServer.getBatchRateLimiter() - .tryAcquire(Integer.valueOf(sendMessageBatchRequestBody.getSize()), EventMeshConstants.DEFAULT_FASTFAIL_TIMEOUT_IN_MILLISECONDS, TimeUnit.MILLISECONDS)) { + .tryAcquire(eventSize, EventMeshConstants.DEFAULT_FASTFAIL_TIMEOUT_IN_MILLISECONDS, TimeUnit.MILLISECONDS)) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( sendMessageBatchResponseHeader, SendMessageBatchResponseBody.buildBody(EventMeshRetCode.EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR.getErrMsg())); eventMeshHTTPServer.metrics.summaryMetrics - .recordSendBatchMsgDiscard(Integer.valueOf(sendMessageBatchRequestBody.getSize())); + .recordSendBatchMsgDiscard(eventSize); asyncContext.onComplete(responseEventMeshCommand); return; } - - String producerGroup = sendMessageBatchRequestBody.getProducerGroup(); EventMeshProducer batchEventMeshProducer = eventMeshHTTPServer.getProducerManager().getEventMeshProducer(producerGroup); batchEventMeshProducer.getMqProducerWrapper().getMeshMQProducer().setExtFields(); @@ -131,24 +179,25 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext long batchStartTime = System.currentTimeMillis(); String remoteAddr = RemotingHelper.parseChannelRemoteAddr(ctx.channel()); - String user = sendMessageBatchRequestHeader.getUsername(); - String pass = sendMessageBatchRequestHeader.getPasswd(); - String subsystem = sendMessageBatchRequestHeader.getSys(); - int requestCode = Integer.valueOf(sendMessageBatchRequestHeader.getCode()); - - List msgList = new ArrayList<>(); - Map> topicBatchMessageMappings = new ConcurrentHashMap>(); - for (SendMessageBatchRequestBody.BatchMessageEntity msg : sendMessageBatchRequestBody.getContents()) { - if (StringUtils.isBlank(msg.topic) - || StringUtils.isBlank(msg.msg)) { + int requestCode = Integer.parseInt(asyncContext.getRequest().getRequestCode()); + + Map> topicBatchMessageMappings = new ConcurrentHashMap>(); + + for (CloudEvent cloudEvent : eventList) { + if (StringUtils.isBlank(cloudEvent.getSubject()) + || cloudEvent.getData() == null) { continue; } + String user = Objects.requireNonNull(cloudEvent.getExtension(ProtocolKey.ClientInstanceKey.USERNAME)).toString(); + String pass = Objects.requireNonNull(cloudEvent.getExtension(ProtocolKey.ClientInstanceKey.PASSWD)).toString(); + String subsystem = Objects.requireNonNull(cloudEvent.getExtension(ProtocolKey.ClientInstanceKey.SYS)).toString(); + //do acl check if(eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshServerSecurityEnable) { try { - Acl.doAclCheckInHttpSend(remoteAddr, user, pass, subsystem, msg.topic, requestCode); - }catch (Exception e){ + Acl.doAclCheckInHttpSend(remoteAddr, user, pass, subsystem, cloudEvent.getSubject(), requestCode); + } catch (Exception e) { //String errorMsg = String.format("CLIENT HAS NO PERMISSION,send failed, topic:%s, subsys:%s, realIp:%s", topic, subsys, realIp); responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( @@ -160,48 +209,34 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext } } - if (StringUtils.isBlank(msg.ttl) || !StringUtils.isNumeric(msg.ttl)) { - msg.ttl = String.valueOf(EventMeshConstants.DEFAULT_MSG_TTL_MILLS); - } - try { -// Message rocketMQMsg; - Message omsMsg = new Message(); - // topic - omsMsg.setTopic(msg.topic); - // body - omsMsg.setBody(msg.msg.getBytes(EventMeshConstants.DEFAULT_CHARSET)); - if (!StringUtils.isBlank(msg.tag)) { - omsMsg.putUserProperties(EventMeshConstants.TAG, msg.tag); + String ttl = Objects.requireNonNull(cloudEvent.getExtension(SendMessageRequestBody.TTL)).toString(); + + if (StringUtils.isBlank(ttl) || !StringUtils.isNumeric(ttl)) { + cloudEvent = CloudEventBuilder.from(cloudEvent) + .withExtension(SendMessageRequestBody.TTL, String.valueOf(EventMeshConstants.DEFAULT_MSG_TTL_MILLS)) + .withExtension("msgtype", "persistent") + .build(); } -// if (StringUtils.isBlank(msg.tag)) { -// rocketMQMsg = new Message(msg.topic, msg.msg.getBytes(EventMeshConstants.DEFAULT_CHARSET)); -// } else { -// rocketMQMsg = new Message(msg.topic, msg.tag, msg.msg.getBytes(EventMeshConstants.DEFAULT_CHARSET)); -// } - omsMsg.putUserProperties("msgType", "persistent"); - // ttl - omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_TIMEOUT, msg.ttl); - //MessageAccessor.putProperty(rocketMQMsg, DeFiBusConstant.PROPERTY_MESSAGE_TTL, msg.ttl); - msgList.add(omsMsg); - if (topicBatchMessageMappings.containsKey(msg.topic)) { - topicBatchMessageMappings.get(msg.topic).add(omsMsg); + + if (topicBatchMessageMappings.containsKey(cloudEvent.getSubject())) { + topicBatchMessageMappings.get(cloudEvent.getSubject()).add(cloudEvent); } else { - List tmp = new ArrayList<>(); - tmp.add(omsMsg); - topicBatchMessageMappings.put(msg.topic, tmp); + List tmp = new ArrayList<>(); + tmp.add(cloudEvent); + topicBatchMessageMappings.put(cloudEvent.getSubject(), tmp); } if (batchMessageLogger.isDebugEnabled()) { - batchMessageLogger.debug("msg2MQMsg suc, msg:{}", msg.msg); + batchMessageLogger.debug("msg2MQMsg suc, event:{}", cloudEvent.getData()); } - } catch (Exception e) { - batchMessageLogger.error("msg2MQMsg err, msg:{}", msg, e); + batchMessageLogger.error("msg2MQMsg err, event:{}", cloudEvent.getData(), e); } + } - if (CollectionUtils.isEmpty(msgList)) { + if (CollectionUtils.isEmpty(eventList)) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( sendMessageBatchResponseHeader, SendMessageBatchResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getErrMsg())); @@ -209,14 +244,14 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext return; } - String sizeStr = sendMessageBatchRequestBody.getSize(); - long delta = StringUtils.isNumeric(sizeStr)? Integer.parseInt(sizeStr) : 0; + long delta = eventSize; eventMeshHTTPServer.metrics.summaryMetrics.recordSendBatchMsg(delta); if (eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshServerBatchMsgBatchEnabled) { - for (List batchMsgs : topicBatchMessageMappings.values()) { + for (List eventlist : topicBatchMessageMappings.values()) { // TODO: Implementation in API. Consider whether to put it in the plug-in. - Message omsMsg = new Message(); + CloudEvent event = null; +// Message omsMsg = new Message(); // try { // msgBatch = msgBatch.generateFromList(batchMsgs); // for (Message message : msgBatch.getMessages()) { @@ -229,8 +264,8 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext // continue; // } - final SendMessageContext sendMessageContext = new SendMessageContext(sendMessageBatchRequestBody.getBatchId(), omsMsg, batchEventMeshProducer, eventMeshHTTPServer); - sendMessageContext.setMessageList(batchMsgs); + final SendMessageContext sendMessageContext = new SendMessageContext(batchId, event, batchEventMeshProducer, eventMeshHTTPServer); + sendMessageContext.setEventList(eventlist); batchEventMeshProducer.send(sendMessageContext, new SendCallback() { @Override public void onSuccess(SendResult sendResult) { @@ -242,16 +277,11 @@ public void onException(OnExceptionContext context) { eventMeshHTTPServer.getHttpRetryer().pushRetry(sendMessageContext.delay(10000)); } -// @Override -// public void onException(Throwable e) { -// batchMessageLogger.warn("", e); -// eventMeshHTTPServer.getHttpRetryer().pushRetry(sendMessageContext.delay(10000)); -// } }); } } else { - for (Message msg : msgList) { - final SendMessageContext sendMessageContext = new SendMessageContext(sendMessageBatchRequestBody.getBatchId(), msg, batchEventMeshProducer, eventMeshHTTPServer); + for (CloudEvent event : eventList) { + final SendMessageContext sendMessageContext = new SendMessageContext(batchId, event, batchEventMeshProducer, eventMeshHTTPServer); batchEventMeshProducer.send(sendMessageContext, new SendCallback() { @Override public void onSuccess(SendResult sendResult) { @@ -264,11 +294,6 @@ public void onException(OnExceptionContext context) { eventMeshHTTPServer.getHttpRetryer().pushRetry(sendMessageContext.delay(10000)); } -// @Override -// public void onException(Throwable e) { -// batchMessageLogger.warn("", e); -// eventMeshHTTPServer.getHttpRetryer().pushRetry(sendMessageContext.delay(10000)); -// } }); } } @@ -276,10 +301,7 @@ public void onException(OnExceptionContext context) { long batchEndTime = System.currentTimeMillis(); eventMeshHTTPServer.metrics.summaryMetrics.recordBatchSendMsgCost(batchEndTime - batchStartTime); batchMessageLogger.debug("batchMessage|eventMesh2mq|REQ|ASYNC|batchId={}|send2MQCost={}ms|msgNum={}|topics={}", - sendMessageBatchRequestBody.getBatchId(), - batchEndTime - batchStartTime, - sendMessageBatchRequestBody.getSize(), - topicBatchMessageMappings.keySet()); + batchId, batchEndTime - batchStartTime, eventSize, topicBatchMessageMappings.keySet()); responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( sendMessageBatchResponseHeader, diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageV2Processor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageV2Processor.java index 10950ec7ec..b15add641d 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageV2Processor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageV2Processor.java @@ -17,22 +17,23 @@ package org.apache.eventmesh.runtime.core.protocol.http.processor; -import io.netty.channel.ChannelHandlerContext; -import io.openmessaging.api.Message; -import io.openmessaging.api.OnExceptionContext; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; -import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.command.HttpCommand; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchV2RequestBody; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchV2ResponseBody; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; import org.apache.eventmesh.common.protocol.http.common.RequestCode; import org.apache.eventmesh.common.protocol.http.header.message.SendMessageBatchV2RequestHeader; import org.apache.eventmesh.common.protocol.http.header.message.SendMessageBatchV2ResponseHeader; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.acl.Acl; import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; import org.apache.eventmesh.runtime.constants.EventMeshConstants; @@ -42,10 +43,18 @@ import org.apache.eventmesh.runtime.core.protocol.http.producer.SendMessageContext; import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.apache.eventmesh.runtime.util.RemotingHelper; + +import org.apache.commons.lang3.StringUtils; + +import java.util.Objects; +import java.util.concurrent.TimeUnit; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.TimeUnit; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import io.netty.channel.ChannelHandlerContext; public class BatchSendMessageV2Processor implements HttpRequestProcessor { @@ -62,196 +71,230 @@ public BatchSendMessageV2Processor(EventMeshHTTPServer eventMeshHTTPServer) { public Logger batchMessageLogger = LoggerFactory.getLogger("batchMessage"); @Override - public void processRequest(ChannelHandlerContext ctx, AsyncContext asyncContext) throws Exception { + public void processRequest(ChannelHandlerContext ctx, AsyncContext asyncContext) + throws Exception { HttpCommand responseEventMeshCommand; + final HttpCommand request = asyncContext.getRequest(); + final Integer requestCode = Integer.valueOf(request.getRequestCode()); - cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", RequestCode.get(Integer.valueOf(asyncContext.getRequest().getRequestCode())), - EventMeshConstants.PROTOCOL_HTTP, - RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtil.getLocalAddress()); + cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", + RequestCode.get(requestCode), + EventMeshConstants.PROTOCOL_HTTP, + RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtils.getLocalAddress()); - SendMessageBatchV2RequestHeader sendMessageBatchV2RequestHeader = (SendMessageBatchV2RequestHeader) asyncContext.getRequest().getHeader(); - SendMessageBatchV2RequestBody sendMessageBatchV2RequestBody = (SendMessageBatchV2RequestBody) asyncContext.getRequest().getBody(); + SendMessageBatchV2RequestHeader sendMessageBatchV2RequestHeader = + (SendMessageBatchV2RequestHeader) asyncContext.getRequest().getHeader(); + + String protocolType = sendMessageBatchV2RequestHeader.getProtocolType(); + ProtocolAdaptor httpCommandProtocolAdaptor = + ProtocolPluginFactory.getProtocolAdaptor(protocolType); + CloudEvent event = httpCommandProtocolAdaptor.toCloudEvent(asyncContext.getRequest()); SendMessageBatchV2ResponseHeader sendMessageBatchV2ResponseHeader = - SendMessageBatchV2ResponseHeader.buildHeader(Integer.valueOf(asyncContext.getRequest().getRequestCode()), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshCluster, - IPUtil.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, - eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshIDC); + SendMessageBatchV2ResponseHeader.buildHeader( + requestCode, + eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshCluster, + IPUtils.getLocalAddress(), + eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, + eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshIDC + ); + + // todo: use validate processor to check + //validate event + if (StringUtils.isBlank(event.getId()) + || event.getSource() == null + || event.getSpecVersion() == null + || StringUtils.isBlank(event.getType()) + || StringUtils.isBlank(event.getSubject())) { + responseEventMeshCommand = request.createHttpCommandResponse( + sendMessageBatchV2ResponseHeader, + SendMessageBatchV2ResponseBody + .buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); + asyncContext.onComplete(responseEventMeshCommand); + return; + } - if (StringUtils.isBlank(sendMessageBatchV2RequestHeader.getPid()) - || !StringUtils.isNumeric(sendMessageBatchV2RequestHeader.getPid()) - || StringUtils.isBlank(sendMessageBatchV2RequestHeader.getSys())) { - responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - sendMessageBatchV2ResponseHeader, - SendMessageBatchV2ResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); + String idc = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.IDC)) + .toString(); + String pid = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.PID)) + .toString(); + String sys = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.SYS)) + .toString(); + + //validate event-extension + if (StringUtils.isBlank(idc) + || StringUtils.isBlank(pid) + || !StringUtils.isNumeric(pid) + || StringUtils.isBlank(sys)) { + responseEventMeshCommand = request.createHttpCommandResponse( + sendMessageBatchV2ResponseHeader, + SendMessageBatchV2ResponseBody + .buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); asyncContext.onComplete(responseEventMeshCommand); return; } - if (StringUtils.isBlank(sendMessageBatchV2RequestBody.getBizSeqNo()) - || StringUtils.isBlank(sendMessageBatchV2RequestBody.getTopic()) - || StringUtils.isBlank(sendMessageBatchV2RequestBody.getProducerGroup()) - || StringUtils.isBlank(sendMessageBatchV2RequestBody.getMsg())) { - responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - sendMessageBatchV2ResponseHeader, - SendMessageBatchV2ResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getErrMsg())); + String bizNo = + Objects.requireNonNull(event.getExtension(SendMessageBatchV2RequestBody.BIZSEQNO)) + .toString(); + String producerGroup = + Objects.requireNonNull(event.getExtension(SendMessageBatchV2RequestBody.PRODUCERGROUP)) + .toString(); + String topic = event.getSubject(); + + if (StringUtils.isBlank(bizNo) + || StringUtils.isBlank(topic) + || StringUtils.isBlank(producerGroup) + || event.getData() == null) { + responseEventMeshCommand = request.createHttpCommandResponse( + sendMessageBatchV2ResponseHeader, + SendMessageBatchV2ResponseBody + .buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getErrMsg())); asyncContext.onComplete(responseEventMeshCommand); return; } //do acl check - if(eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshServerSecurityEnable) { + if (eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshServerSecurityEnable) { String remoteAddr = RemotingHelper.parseChannelRemoteAddr(ctx.channel()); - String user = sendMessageBatchV2RequestHeader.getUsername(); - String pass = sendMessageBatchV2RequestHeader.getPasswd(); - String subsystem = sendMessageBatchV2RequestHeader.getSys(); - int requestCode = Integer.valueOf(sendMessageBatchV2RequestHeader.getCode()); - String topic = sendMessageBatchV2RequestBody.getTopic(); + String user = event.getExtension(ProtocolKey.ClientInstanceKey.USERNAME).toString(); + String pass = event.getExtension(ProtocolKey.ClientInstanceKey.PASSWD).toString(); + String subsystem = event.getExtension(ProtocolKey.ClientInstanceKey.SYS).toString(); try { Acl.doAclCheckInHttpSend(remoteAddr, user, pass, subsystem, topic, requestCode); - }catch (Exception e){ + } catch (Exception e) { //String errorMsg = String.format("CLIENT HAS NO PERMISSION,send failed, topic:%s, subsys:%s, realIp:%s", topic, subsys, realIp); responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - sendMessageBatchV2ResponseHeader, - SendMessageResponseBody.buildBody(EventMeshRetCode.EVENTMESH_ACL_ERR.getRetCode(), e.getMessage())); + sendMessageBatchV2ResponseHeader, + SendMessageResponseBody + .buildBody(EventMeshRetCode.EVENTMESH_ACL_ERR.getRetCode(), + e.getMessage())); asyncContext.onComplete(responseEventMeshCommand); - aclLogger.warn("CLIENT HAS NO PERMISSION,BatchSendMessageV2Processor send failed", e); + aclLogger + .warn("CLIENT HAS NO PERMISSION,BatchSendMessageV2Processor send failed", e); return; } } if (!eventMeshHTTPServer.getBatchRateLimiter() - .tryAcquire(EventMeshConstants.DEFAULT_FASTFAIL_TIMEOUT_IN_MILLISECONDS, TimeUnit.MILLISECONDS)) { - responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - sendMessageBatchV2ResponseHeader, - SendMessageBatchV2ResponseBody.buildBody(EventMeshRetCode.EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR.getErrMsg())); + .tryAcquire(EventMeshConstants.DEFAULT_FASTFAIL_TIMEOUT_IN_MILLISECONDS, + TimeUnit.MILLISECONDS)) { + responseEventMeshCommand = request.createHttpCommandResponse( + sendMessageBatchV2ResponseHeader, + SendMessageBatchV2ResponseBody + .buildBody(EventMeshRetCode.EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR.getErrMsg())); eventMeshHTTPServer.metrics.summaryMetrics - .recordSendBatchMsgDiscard(1); + .recordSendBatchMsgDiscard(1); asyncContext.onComplete(responseEventMeshCommand); return; } - String producerGroup = sendMessageBatchV2RequestBody.getProducerGroup(); - EventMeshProducer batchEventMeshProducer = eventMeshHTTPServer.getProducerManager().getEventMeshProducer(producerGroup); + EventMeshProducer batchEventMeshProducer = + eventMeshHTTPServer.getProducerManager().getEventMeshProducer(producerGroup); batchEventMeshProducer.getMqProducerWrapper().getMeshMQProducer().setExtFields(); -// batchEventMeshProducer.getMqProducerWrapper().getDefaultMQProducer().setRetryTimesWhenSendAsyncFailed(0); -// batchEventMeshProducer.getMqProducerWrapper().getDefaultMQProducer().setPollNameServerInterval(60000); -// -// batchEventMeshProducer.getMqProducerWrapper().getDefaultMQProducer().getDefaultMQProducerImpl().getmQClientFactory() -// .getNettyClientConfig().setClientAsyncSemaphoreValue(eventMeshHTTPServer.getEventMeshConfiguration().eventMeshServerAsyncAccumulationThreshold); -// batchEventMeshProducer.getMqProducerWrapper().getDefaultMQProducer().setCompressMsgBodyOverHowmuch(10); if (!batchEventMeshProducer.getStarted().get()) { - responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - sendMessageBatchV2ResponseHeader, - SendMessageBatchV2ResponseBody.buildBody(EventMeshRetCode.EVENTMESH_BATCH_PRODUCER_STOPED_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_BATCH_PRODUCER_STOPED_ERR.getErrMsg())); + responseEventMeshCommand = request.createHttpCommandResponse( + sendMessageBatchV2ResponseHeader, + SendMessageBatchV2ResponseBody + .buildBody(EventMeshRetCode.EVENTMESH_BATCH_PRODUCER_STOPED_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_BATCH_PRODUCER_STOPED_ERR.getErrMsg())); asyncContext.onComplete(responseEventMeshCommand); return; } long batchStartTime = System.currentTimeMillis(); - if (StringUtils.isBlank(sendMessageBatchV2RequestBody.getTtl()) || !StringUtils.isNumeric(sendMessageBatchV2RequestBody.getTtl())) { - sendMessageBatchV2RequestBody.setTtl(String.valueOf(EventMeshConstants.DEFAULT_MSG_TTL_MILLS)); + String ttl = String.valueOf(EventMeshConstants.DEFAULT_MSG_TTL_MILLS); + // todo: use hashmap to avoid copy + if (StringUtils.isBlank(event.getExtension(SendMessageRequestBody.TTL).toString()) + && !StringUtils.isNumeric(event.getExtension(SendMessageRequestBody.TTL).toString())) { + event = CloudEventBuilder.from(event).withExtension(SendMessageRequestBody.TTL, ttl) + .build(); } -// Message rocketMQMsg = null; - Message omsMsg = new Message(); try { -// if (StringUtils.isBlank(sendMessageBatchV2RequestBody.getTag())) { -// rocketMQMsg = new Message(sendMessageBatchV2RequestBody.getTopic(), sendMessageBatchV2RequestBody.getMsg().getBytes(EventMeshConstants.DEFAULT_CHARSET)); -// } else { -// rocketMQMsg = new Message(sendMessageBatchV2RequestBody.getTopic(), sendMessageBatchV2RequestBody.getTag(), -// sendMessageBatchV2RequestBody.getMsg().getBytes(EventMeshConstants.DEFAULT_CHARSET)); -// } - // body - omsMsg.setBody(sendMessageBatchV2RequestBody.getMsg().getBytes(EventMeshConstants.DEFAULT_CHARSET)); - // topic - // topic - omsMsg.setTopic(sendMessageBatchV2RequestBody.getTopic()); - omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION, sendMessageBatchV2RequestBody.getTopic()); - if (!StringUtils.isBlank(sendMessageBatchV2RequestBody.getTag())) { - omsMsg.putUserProperties(EventMeshConstants.TAG, sendMessageBatchV2RequestBody.getTag()); - } - omsMsg.putUserProperties("msgType", "persistent"); - // ttl - omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_TIMEOUT, sendMessageBatchV2RequestBody.getTtl()); - -// rocketMQMsg.putUserProperty(DeFiBusConstant.KEY, DeFiBusConstant.PERSISTENT); -// MessageAccessor.putProperty(rocketMQMsg, DeFiBusConstant.PROPERTY_MESSAGE_TTL, sendMessageBatchV2RequestBody.getTtl()); - + event = CloudEventBuilder.from(event) + .withExtension("msgtype", "persistent") + .withExtension(EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP, + String.valueOf(System.currentTimeMillis())) + .withExtension(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, + String.valueOf(System.currentTimeMillis())) + .build(); if (batchMessageLogger.isDebugEnabled()) { - batchMessageLogger.debug("msg2MQMsg suc, topic:{}, msg:{}", sendMessageBatchV2RequestBody.getTopic(), sendMessageBatchV2RequestBody.getMsg()); + batchMessageLogger.debug("msg2MQMsg suc, topic:{}, msg:{}", topic, event.getData()); } } catch (Exception e) { - batchMessageLogger.error("msg2MQMsg err, topic:{}, msg:{}", sendMessageBatchV2RequestBody.getTopic(), sendMessageBatchV2RequestBody.getMsg(), e); + batchMessageLogger.error("msg2MQMsg err, topic:{}, msg:{}", topic, event.getData(), e); responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - sendMessageBatchV2ResponseHeader, - SendMessageBatchV2ResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PACKAGE_MSG_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PACKAGE_MSG_ERR.getErrMsg() + EventMeshUtil.stackTrace(e, 2))); + sendMessageBatchV2ResponseHeader, + SendMessageBatchV2ResponseBody + .buildBody(EventMeshRetCode.EVENTMESH_PACKAGE_MSG_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_PACKAGE_MSG_ERR.getErrMsg() + + EventMeshUtil.stackTrace(e, 2))); asyncContext.onComplete(responseEventMeshCommand); return; } eventMeshHTTPServer.metrics.summaryMetrics.recordSendBatchMsg(1); - final SendMessageContext sendMessageContext = new SendMessageContext(sendMessageBatchV2RequestBody.getBizSeqNo(), omsMsg, batchEventMeshProducer, eventMeshHTTPServer); + final SendMessageContext sendMessageContext = + new SendMessageContext(bizNo, event, batchEventMeshProducer, eventMeshHTTPServer); try { batchEventMeshProducer.send(sendMessageContext, new SendCallback() { @Override public void onSuccess(SendResult sendResult) { long batchEndTime = System.currentTimeMillis(); - eventMeshHTTPServer.metrics.summaryMetrics.recordBatchSendMsgCost(batchEndTime - batchStartTime); - batchMessageLogger.debug("batchMessageV2|eventMesh2mq|REQ|ASYNC|bizSeqNo={}|send2MQCost={}ms|topic={}", - sendMessageBatchV2RequestBody.getBizSeqNo(), - batchEndTime - batchStartTime, - sendMessageBatchV2RequestBody.getTopic()); + eventMeshHTTPServer.metrics.summaryMetrics + .recordBatchSendMsgCost(batchEndTime - batchStartTime); + batchMessageLogger.debug( + "batchMessageV2|eventMesh2mq|REQ|ASYNC|bizSeqNo={}|send2MQCost={}ms|topic={}", + bizNo, batchEndTime - batchStartTime, topic); } @Override public void onException(OnExceptionContext context) { long batchEndTime = System.currentTimeMillis(); eventMeshHTTPServer.getHttpRetryer().pushRetry(sendMessageContext.delay(10000)); - eventMeshHTTPServer.metrics.summaryMetrics.recordBatchSendMsgCost(batchEndTime - batchStartTime); - batchMessageLogger.error("batchMessageV2|eventMesh2mq|REQ|ASYNC|bizSeqNo={}|send2MQCost={}ms|topic={}", - sendMessageBatchV2RequestBody.getBizSeqNo(), - batchEndTime - batchStartTime, - sendMessageBatchV2RequestBody.getTopic(), context.getException()); + eventMeshHTTPServer.metrics.summaryMetrics + .recordBatchSendMsgCost(batchEndTime - batchStartTime); + batchMessageLogger.error( + "batchMessageV2|eventMesh2mq|REQ|ASYNC|bizSeqNo={}|send2MQCost={}ms|topic={}", + bizNo, batchEndTime - batchStartTime, topic, context.getException()); } -// @Override -// public void onException(Throwable e) { -// long batchEndTime = System.currentTimeMillis(); -// eventMeshHTTPServer.getHttpRetryer().pushRetry(sendMessageContext.delay(10000)); -// eventMeshHTTPServer.metrics.summaryMetrics.recordBatchSendMsgCost(batchEndTime - batchStartTime); -// batchMessageLogger.error("batchMessageV2|eventMesh2mq|REQ|ASYNC|bizSeqNo={}|send2MQCost={}ms|topic={}", -// sendMessageBatchV2RequestBody.getBizSeqNo(), -// batchEndTime - batchStartTime, -// sendMessageBatchV2RequestBody.getTopic(), e); -// } }); } catch (Exception e) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - sendMessageBatchV2ResponseHeader, - SendMessageBatchV2ResponseBody.buildBody(EventMeshRetCode.EVENTMESH_SEND_BATCHLOG_MSG_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_SEND_BATCHLOG_MSG_ERR.getErrMsg() + EventMeshUtil.stackTrace(e, 2))); + sendMessageBatchV2ResponseHeader, + SendMessageBatchV2ResponseBody + .buildBody(EventMeshRetCode.EVENTMESH_SEND_BATCHLOG_MSG_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_SEND_BATCHLOG_MSG_ERR.getErrMsg() + + EventMeshUtil.stackTrace(e, 2))); asyncContext.onComplete(responseEventMeshCommand); long batchEndTime = System.currentTimeMillis(); eventMeshHTTPServer.getHttpRetryer().pushRetry(sendMessageContext.delay(10000)); - eventMeshHTTPServer.metrics.summaryMetrics.recordBatchSendMsgCost(batchEndTime - batchStartTime); - batchMessageLogger.error("batchMessageV2|eventMesh2mq|REQ|ASYNC|bizSeqNo={}|send2MQCost={}ms|topic={}", - sendMessageBatchV2RequestBody.getBizSeqNo(), - batchEndTime - batchStartTime, - sendMessageBatchV2RequestBody.getTopic(), e); + eventMeshHTTPServer.metrics.summaryMetrics + .recordBatchSendMsgCost(batchEndTime - batchStartTime); + batchMessageLogger.error( + "batchMessageV2|eventMesh2mq|REQ|ASYNC|bizSeqNo={}|send2MQCost={}ms|topic={}", + bizNo, batchEndTime - batchStartTime, topic, e); } responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - sendMessageBatchV2ResponseHeader, - SendMessageBatchV2ResponseBody.buildBody(EventMeshRetCode.SUCCESS.getRetCode(), EventMeshRetCode.SUCCESS.getErrMsg())); + sendMessageBatchV2ResponseHeader, + SendMessageBatchV2ResponseBody.buildBody(EventMeshRetCode.SUCCESS.getRetCode(), + EventMeshRetCode.SUCCESS.getErrMsg())); asyncContext.onComplete(responseEventMeshCommand); - return; } @Override diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/HeartBeatProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/HeartBeatProcessor.java index e0341cfd63..45e21dae42 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/HeartBeatProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/HeartBeatProcessor.java @@ -17,18 +17,8 @@ package org.apache.eventmesh.runtime.core.protocol.http.processor; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import io.netty.channel.ChannelHandlerContext; - -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.command.HttpCommand; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.http.body.client.HeartbeatRequestBody; import org.apache.eventmesh.common.protocol.http.body.client.HeartbeatResponseBody; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; @@ -45,9 +35,21 @@ import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.apache.eventmesh.runtime.util.RemotingHelper; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.netty.channel.ChannelHandlerContext; + public class HeartBeatProcessor implements HttpRequestProcessor { public Logger httpLogger = LoggerFactory.getLogger("http"); @@ -63,38 +65,42 @@ public HeartBeatProcessor(EventMeshHTTPServer eventMeshHTTPServer) { @Override public void processRequest(ChannelHandlerContext ctx, AsyncContext asyncContext) throws Exception { HttpCommand responseEventMeshCommand; - httpLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", RequestCode.get(Integer.valueOf(asyncContext.getRequest().getRequestCode())), - EventMeshConstants.PROTOCOL_HTTP, - RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtil.getLocalAddress()); + httpLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", + RequestCode.get(Integer.valueOf(asyncContext.getRequest().getRequestCode())), + EventMeshConstants.PROTOCOL_HTTP, + RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtils.getLocalAddress()); HeartbeatRequestHeader heartbeatRequestHeader = (HeartbeatRequestHeader) asyncContext.getRequest().getHeader(); HeartbeatRequestBody heartbeatRequestBody = (HeartbeatRequestBody) asyncContext.getRequest().getBody(); HeartbeatResponseHeader heartbeatResponseHeader = - HeartbeatResponseHeader.buildHeader(Integer.valueOf(asyncContext.getRequest().getRequestCode()), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshCluster, - IPUtil.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, - eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshIDC); + HeartbeatResponseHeader.buildHeader(Integer.valueOf(asyncContext.getRequest().getRequestCode()), + eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshCluster, + IPUtils.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, + eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshIDC); //validate header if (StringUtils.isBlank(heartbeatRequestHeader.getIdc()) - || StringUtils.isBlank(heartbeatRequestHeader.getPid()) - || !StringUtils.isNumeric(heartbeatRequestHeader.getPid()) - || StringUtils.isBlank(heartbeatRequestHeader.getSys())) { + || StringUtils.isBlank(heartbeatRequestHeader.getPid()) + || !StringUtils.isNumeric(heartbeatRequestHeader.getPid()) + || StringUtils.isBlank(heartbeatRequestHeader.getSys())) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - heartbeatResponseHeader, - HeartbeatResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); + heartbeatResponseHeader, + HeartbeatResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); asyncContext.onComplete(responseEventMeshCommand); return; } //validate body if (StringUtils.isBlank(heartbeatRequestBody.getClientType()) - || StringUtils.isBlank(heartbeatRequestBody.getConsumerGroup()) - || CollectionUtils.isEmpty(heartbeatRequestBody.getHeartbeatEntities())) { + || StringUtils.isBlank(heartbeatRequestBody.getConsumerGroup()) + || CollectionUtils.isEmpty(heartbeatRequestBody.getHeartbeatEntities())) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - heartbeatResponseHeader, - HeartbeatResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getErrMsg())); + heartbeatResponseHeader, + HeartbeatResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getErrMsg())); asyncContext.onComplete(responseEventMeshCommand); return; } @@ -126,7 +132,7 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext } //do acl check - if(eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshServerSecurityEnable) { + if (eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshServerSecurityEnable) { String remoteAddr = RemotingHelper.parseChannelRemoteAddr(ctx.channel()); String user = heartbeatRequestHeader.getUsername(); String pass = heartbeatRequestHeader.getPasswd(); @@ -137,8 +143,9 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext //String errorMsg = String.format("CLIENT HAS NO PERMISSION,send failed, topic:%s, subsys:%s, realIp:%s", topic, subsys, realIp); responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - heartbeatResponseHeader, - SendMessageResponseBody.buildBody(EventMeshRetCode.EVENTMESH_ACL_ERR.getRetCode(), e.getMessage())); + heartbeatResponseHeader, + SendMessageResponseBody + .buildBody(EventMeshRetCode.EVENTMESH_ACL_ERR.getRetCode(), e.getMessage())); asyncContext.onComplete(responseEventMeshCommand); aclLogger.warn("CLIENT HAS NO PERMISSION,HeartBeatProcessor subscribe failed", e); return; @@ -161,9 +168,11 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext } synchronized (eventMeshHTTPServer.localClientInfoMapping) { for (Map.Entry> groupTopicClientMapping : tmp.entrySet()) { - List localClientList = eventMeshHTTPServer.localClientInfoMapping.get(groupTopicClientMapping.getKey()); + List localClientList = + eventMeshHTTPServer.localClientInfoMapping.get(groupTopicClientMapping.getKey()); if (CollectionUtils.isEmpty(localClientList)) { - eventMeshHTTPServer.localClientInfoMapping.put(groupTopicClientMapping.getKey(), groupTopicClientMapping.getValue()); + eventMeshHTTPServer.localClientInfoMapping + .put(groupTopicClientMapping.getKey(), groupTopicClientMapping.getValue()); } else { List tmpClientList = groupTopicClientMapping.getValue(); supplyClientInfoList(tmpClientList, localClientList); @@ -184,24 +193,24 @@ public void onResponse(HttpCommand httpCommand) { httpLogger.debug("{}", httpCommand); } eventMeshHTTPServer.sendResponse(ctx, httpCommand.httpResponse()); - eventMeshHTTPServer.metrics.summaryMetrics.recordHTTPReqResTimeCost(System.currentTimeMillis() - asyncContext.getRequest().getReqTime()); + eventMeshHTTPServer.metrics.summaryMetrics.recordHTTPReqResTimeCost( + System.currentTimeMillis() - asyncContext.getRequest().getReqTime()); } catch (Exception ex) { } } }; - responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - EventMeshRetCode.SUCCESS.getRetCode(), EventMeshRetCode.SUCCESS.getErrMsg()); + responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse(EventMeshRetCode.SUCCESS); asyncContext.onComplete(responseEventMeshCommand, handler); } catch (Exception e) { HttpCommand err = asyncContext.getRequest().createHttpCommandResponse( - heartbeatResponseHeader, - HeartbeatResponseBody.buildBody(EventMeshRetCode.EVENTMESH_HEARTBEAT_ERR.getRetCode(), - EventMeshRetCode.EVENTMESH_HEARTBEAT_ERR.getErrMsg() + EventMeshUtil.stackTrace(e, 2))); + heartbeatResponseHeader, + HeartbeatResponseBody.buildBody(EventMeshRetCode.EVENTMESH_HEARTBEAT_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_HEARTBEAT_ERR.getErrMsg() + EventMeshUtil.stackTrace(e, 2))); asyncContext.onComplete(err); long endTime = System.currentTimeMillis(); httpLogger.error("message|eventMesh2mq|REQ|ASYNC|heartBeatMessageCost={}ms", - endTime - startTime, e); + endTime - startTime, e); eventMeshHTTPServer.metrics.summaryMetrics.recordSendMsgFailed(); eventMeshHTTPServer.metrics.summaryMetrics.recordSendMsgCost(endTime - startTime); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/ReplyMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/ReplyMessageProcessor.java index fb780dba97..8114f4cc90 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/ReplyMessageProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/ReplyMessageProcessor.java @@ -17,23 +17,28 @@ package org.apache.eventmesh.runtime.core.protocol.http.processor; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; import io.netty.channel.ChannelHandlerContext; -import io.openmessaging.api.Message; -import io.openmessaging.api.OnExceptionContext; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; -import org.apache.commons.collections4.MapUtils; + import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.command.HttpCommand; -import org.apache.eventmesh.common.protocol.http.body.message.ReplyMessageRequestBody; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.http.body.message.ReplyMessageResponseBody; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; import org.apache.eventmesh.common.protocol.http.common.RequestCode; import org.apache.eventmesh.common.protocol.http.header.message.ReplyMessageRequestHeader; import org.apache.eventmesh.common.protocol.http.header.message.ReplyMessageResponseHeader; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.http.async.AsyncContext; @@ -46,7 +51,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Map; +import java.util.Objects; import java.util.concurrent.TimeUnit; public class ReplyMessageProcessor implements HttpRequestProcessor { @@ -69,21 +74,43 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", RequestCode.get(Integer.valueOf(asyncContext.getRequest().getRequestCode())), EventMeshConstants.PROTOCOL_HTTP, - RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtil.getLocalAddress()); + RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtils.getLocalAddress()); ReplyMessageRequestHeader replyMessageRequestHeader = (ReplyMessageRequestHeader) asyncContext.getRequest().getHeader(); - ReplyMessageRequestBody replyMessageRequestBody = (ReplyMessageRequestBody) asyncContext.getRequest().getBody(); +// ReplyMessageRequestBody replyMessageRequestBody = (ReplyMessageRequestBody) asyncContext.getRequest().getBody(); + + String protocolType = replyMessageRequestHeader.getProtocolType(); + ProtocolAdaptor httpCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + CloudEvent event = httpCommandProtocolAdaptor.toCloudEvent(asyncContext.getRequest()); ReplyMessageResponseHeader replyMessageResponseHeader = ReplyMessageResponseHeader.buildHeader(Integer.valueOf(asyncContext.getRequest().getRequestCode()), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshCluster, - IPUtil.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, + IPUtils.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshIDC); + //validate event + if (event == null + || StringUtils.isBlank(event.getId()) + || event.getSource() == null + || event.getSpecVersion() == null + || StringUtils.isBlank(event.getType()) + || StringUtils.isBlank(event.getSubject())) { + responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( + replyMessageResponseHeader, + ReplyMessageResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); + asyncContext.onComplete(responseEventMeshCommand); + return; + } + + String idc = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.IDC)).toString(); + String pid = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.PID)).toString(); + String sys = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.SYS)).toString(); + //validate HEADER - if (StringUtils.isBlank(replyMessageRequestHeader.getIdc()) - || StringUtils.isBlank(replyMessageRequestHeader.getPid()) - || !StringUtils.isNumeric(replyMessageRequestHeader.getPid()) - || StringUtils.isBlank(replyMessageRequestHeader.getSys())) { + if (StringUtils.isBlank(idc) + || StringUtils.isBlank(pid) + || !StringUtils.isNumeric(pid) + || StringUtils.isBlank(sys)) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( replyMessageResponseHeader, ReplyMessageResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); @@ -91,11 +118,15 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext return; } + String bizNo = Objects.requireNonNull(event.getExtension(SendMessageRequestBody.BIZSEQNO)).toString(); + String uniqueId = Objects.requireNonNull(event.getExtension(SendMessageRequestBody.UNIQUEID)).toString(); + String producerGroup = Objects.requireNonNull(event.getExtension(SendMessageRequestBody.PRODUCERGROUP)).toString(); + //validate body - if (StringUtils.isBlank(replyMessageRequestBody.getBizSeqNo()) - || StringUtils.isBlank(replyMessageRequestBody.getUniqueId()) - || StringUtils.isBlank(replyMessageRequestBody.getProducerGroup()) - || StringUtils.isBlank(replyMessageRequestBody.getContent())) { + if (StringUtils.isBlank(bizNo) + || StringUtils.isBlank(uniqueId) + || StringUtils.isBlank(producerGroup) + || event.getData() == null) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( replyMessageResponseHeader, ReplyMessageResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getErrMsg())); @@ -115,7 +146,6 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext return; } - String producerGroup = replyMessageRequestBody.getProducerGroup(); EventMeshProducer eventMeshProducer = eventMeshHTTPServer.getProducerManager().getEventMeshProducer(producerGroup); if (!eventMeshProducer.getStarted().get()) { @@ -129,11 +159,14 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext long startTime = System.currentTimeMillis(); // Message rocketMQMsg; - Message omsMsg = new Message(); +// Message omsMsg = new Message(); String replyTopic = EventMeshConstants.RR_REPLY_TOPIC; - Map extFields = replyMessageRequestBody.getExtFields(); - final String replyMQCluster = MapUtils.getString(extFields, EventMeshConstants.PROPERTY_MESSAGE_CLUSTER, null); + String origTopic = event.getSubject(); + +// Map extFields = replyMessageRequestBody.getExtFields(); + final String replyMQCluster = event.getExtension(EventMeshConstants.PROPERTY_MESSAGE_CLUSTER).toString(); +// final String replyMQCluster = MapUtils.getString(extFields, EventMeshConstants.PROPERTY_MESSAGE_CLUSTER, null); if (!org.apache.commons.lang3.StringUtils.isEmpty(replyMQCluster)) { replyTopic = replyMQCluster + "-" + replyTopic; } else { @@ -146,37 +179,41 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext try { // body - omsMsg.setBody(replyMessageRequestBody.getContent().getBytes(EventMeshConstants.DEFAULT_CHARSET)); - omsMsg.setTopic(replyTopic); +// omsMsg.setBody(replyMessageRequestBody.getContent().getBytes(EventMeshConstants.DEFAULT_CHARSET)); + event = CloudEventBuilder.from(event) + .withSubject(replyTopic) + .withExtension("msgtype", "persistent") + .withExtension(Constants.PROPERTY_MESSAGE_TIMEOUT, String.valueOf(EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS)) + .withExtension(EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .build(); +// omsMsg.setTopic(replyTopic); // topic - omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION, replyTopic); +// omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION, replyTopic); // if (!StringUtils.isBlank(sendMessageRequestBody.getTag())) { // omsMsg.putUserHeaders("Tag", sendMessageRequestBody.getTag()); // } // rocketMQMsg = new Message(replyTopic, // replyMessageRequestBody.getContent().getBytes(EventMeshConstants.DEFAULT_CHARSET)); - omsMsg.putUserProperties("msgType", "persistent"); +// omsMsg.putUserProperties("msgType", "persistent"); // rocketMQMsg.putUserProperty(DeFiBusConstant.KEY, DeFiBusConstant.PERSISTENT); - for (Map.Entry entry : extFields.entrySet()) { - omsMsg.putUserProperties(entry.getKey(), entry.getValue()); - } +// for (Map.Entry entry : extFields.entrySet()) { +// omsMsg.putUserProperties(entry.getKey(), entry.getValue()); +// } // //for rocketmq support // MessageAccessor.putProperty(rocketMQMsg, MessageConst.PROPERTY_MESSAGE_TYPE, MixAll.REPLY_MESSAGE_FLAG); // MessageAccessor.putProperty(rocketMQMsg, MessageConst.PROPERTY_CORRELATION_ID, rocketMQMsg.getProperty(DeFiBusConstant.PROPERTY_RR_REQUEST_ID)); // MessageAccessor.putProperty(rocketMQMsg, MessageConst.PROPERTY_MESSAGE_REPLY_TO_CLIENT, rocketMQMsg.getProperty(DeFiBusConstant.PROPERTY_MESSAGE_REPLY_TO)); // ttl - omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_TIMEOUT, String.valueOf(EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS)); -// MessageAccessor.putProperty(rocketMQMsg, DeFiBusConstant.PROPERTY_MESSAGE_TTL, String.valueOf(EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS)); - omsMsg.putUserProperties(EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())); +// omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_TIMEOUT, String.valueOf(EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS)); +//// MessageAccessor.putProperty(rocketMQMsg, DeFiBusConstant.PROPERTY_MESSAGE_TTL, String.valueOf(EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS)); +// omsMsg.putUserProperties(EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())); if (messageLogger.isDebugEnabled()) { - messageLogger.debug("msg2MQMsg suc, bizSeqNo={}, topic={}", replyMessageRequestBody.getBizSeqNo(), - replyTopic); + messageLogger.debug("msg2MQMsg suc, bizSeqNo={}, topic={}", bizNo, replyTopic); } } catch (Exception e) { - messageLogger.error("msg2MQMsg err, bizSeqNo={}, topic={}", replyMessageRequestBody.getBizSeqNo(), - replyTopic, e); + messageLogger.error("msg2MQMsg err, bizSeqNo={}, topic={}", bizNo, replyTopic, e); responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( replyMessageResponseHeader, ReplyMessageResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PACKAGE_MSG_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PACKAGE_MSG_ERR.getErrMsg() + EventMeshUtil.stackTrace(e, 2))); @@ -184,7 +221,7 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext return; } - final SendMessageContext sendMessageContext = new SendMessageContext(replyMessageRequestBody.getBizSeqNo(), omsMsg, eventMeshProducer, eventMeshHTTPServer); + final SendMessageContext sendMessageContext = new SendMessageContext(bizNo, event, eventMeshProducer, eventMeshHTTPServer); eventMeshHTTPServer.metrics.summaryMetrics.recordReplyMsg(); CompleteHandler handler = new CompleteHandler() { @@ -201,12 +238,12 @@ public void onResponse(HttpCommand httpCommand) { } }; -// LiteMessage liteMessage = new LiteMessage(replyMessageRequestBody.getBizSeqNo(), -// replyMessageRequestBody.getUniqueId(), replyMessageRequestBody.getOrigTopic(), -// replyMessageRequestBody.getContent()); try { - sendMessageContext.getMsg().getUserProperties().put(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, String.valueOf(System.currentTimeMillis())); + CloudEvent clone = CloudEventBuilder.from(sendMessageContext.getEvent()) + .withExtension(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .build(); + sendMessageContext.setEvent(clone); eventMeshProducer.reply(sendMessageContext, new SendCallback() { @Override public void onSuccess(SendResult sendResult) { @@ -217,11 +254,8 @@ public void onSuccess(SendResult sendResult) { long endTime = System.currentTimeMillis(); eventMeshHTTPServer.metrics.summaryMetrics.recordReplyMsgCost(endTime - startTime); messageLogger.info("message|eventMesh2mq|RSP|SYNC|reply2MQCost={}|topic={}|origTopic={}|bizSeqNo={}|uniqueId={}", - endTime - startTime, - replyMQCluster + "-" + EventMeshConstants.RR_REPLY_TOPIC, - replyMessageRequestBody.getOrigTopic(), - replyMessageRequestBody.getBizSeqNo(), - replyMessageRequestBody.getUniqueId()); + endTime - startTime, replyMQCluster + "-" + EventMeshConstants.RR_REPLY_TOPIC, + origTopic, bizNo, uniqueId); } @Override @@ -235,11 +269,8 @@ public void onException(OnExceptionContext context) { eventMeshHTTPServer.metrics.summaryMetrics.recordReplyMsgFailed(); eventMeshHTTPServer.metrics.summaryMetrics.recordReplyMsgCost(endTime - startTime); messageLogger.error("message|eventMesh2mq|RSP|SYNC|reply2MQCost={}|topic={}|origTopic={}|bizSeqNo={}|uniqueId={}", - endTime - startTime, - replyMQCluster + "-" + EventMeshConstants.RR_REPLY_TOPIC, - replyMessageRequestBody.getOrigTopic(), - replyMessageRequestBody.getBizSeqNo(), - replyMessageRequestBody.getUniqueId(), context.getException()); + endTime - startTime, replyMQCluster + "-" + EventMeshConstants.RR_REPLY_TOPIC, + origTopic, bizNo, uniqueId, context.getException()); } // @Override @@ -268,11 +299,7 @@ public void onException(OnExceptionContext context) { asyncContext.onComplete(err); long endTime = System.currentTimeMillis(); messageLogger.error("message|eventMesh2mq|RSP|SYNC|reply2MQCost={}|topic={}|origTopic={}|bizSeqNo={}|uniqueId={}", - endTime - startTime, - replyTopic, - replyMessageRequestBody.getOrigTopic(), - replyMessageRequestBody.getBizSeqNo(), - replyMessageRequestBody.getUniqueId(), ex); + endTime - startTime, replyTopic, origTopic, bizNo, uniqueId, ex); eventMeshHTTPServer.metrics.summaryMetrics.recordReplyMsgFailed(); eventMeshHTTPServer.metrics.summaryMetrics.recordReplyMsgCost(endTime - startTime); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendAsyncMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendAsyncMessageProcessor.java index 3649dd0e35..5cbbd302de 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendAsyncMessageProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendAsyncMessageProcessor.java @@ -17,22 +17,24 @@ package org.apache.eventmesh.runtime.core.protocol.http.processor; -import io.netty.channel.ChannelHandlerContext; -import io.openmessaging.api.Message; -import io.openmessaging.api.OnExceptionContext; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; +import io.cloudevents.core.builder.CloudEventBuilder; + import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.LiteMessage; -import org.apache.eventmesh.common.command.HttpCommand; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; import org.apache.eventmesh.common.protocol.http.common.RequestCode; import org.apache.eventmesh.common.protocol.http.header.message.SendMessageRequestHeader; import org.apache.eventmesh.common.protocol.http.header.message.SendMessageResponseHeader; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.acl.Acl; import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; import org.apache.eventmesh.runtime.constants.EventMeshConstants; @@ -46,8 +48,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Objects; import java.util.concurrent.TimeUnit; +import io.cloudevents.CloudEvent; +import io.netty.channel.ChannelHandlerContext; + public class SendAsyncMessageProcessor implements HttpRequestProcessor { public Logger messageLogger = LoggerFactory.getLogger("message"); @@ -71,21 +77,27 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", RequestCode.get(Integer.valueOf(asyncContext.getRequest().getRequestCode())), EventMeshConstants.PROTOCOL_HTTP, - RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtil.getLocalAddress()); + RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtils.getLocalAddress()); SendMessageRequestHeader sendMessageRequestHeader = (SendMessageRequestHeader) asyncContext.getRequest().getHeader(); - SendMessageRequestBody sendMessageRequestBody = (SendMessageRequestBody) asyncContext.getRequest().getBody(); +// SendMessageRequestBody sendMessageRequestBody = (SendMessageRequestBody) asyncContext.getRequest().getBody(); SendMessageResponseHeader sendMessageResponseHeader = SendMessageResponseHeader.buildHeader(Integer.valueOf(asyncContext.getRequest().getRequestCode()), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshCluster, - IPUtil.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, + IPUtils.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshIDC); - //validate header - if (StringUtils.isBlank(sendMessageRequestHeader.getIdc()) - || StringUtils.isBlank(sendMessageRequestHeader.getPid()) - || !StringUtils.isNumeric(sendMessageRequestHeader.getPid()) - || StringUtils.isBlank(sendMessageRequestHeader.getSys())) { + String protocolType = sendMessageRequestHeader.getProtocolType(); + ProtocolAdaptor httpCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + CloudEvent event = httpCommandProtocolAdaptor.toCloudEvent(asyncContext.getRequest()); + + //validate event + if (event == null + || StringUtils.isBlank(event.getId()) + || event.getSource() == null + || event.getSpecVersion() == null + || StringUtils.isBlank(event.getType()) + || StringUtils.isBlank(event.getSubject())) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( sendMessageResponseHeader, SendMessageResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); @@ -93,14 +105,33 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext return; } + String idc = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.IDC)).toString(); + String pid = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.PID)).toString(); + String sys = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.SYS)).toString(); + + //validate event-extension + if (StringUtils.isBlank(idc) + || StringUtils.isBlank(pid) + || !StringUtils.isNumeric(pid) + || StringUtils.isBlank(sys)) { + responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( + sendMessageResponseHeader, + SendMessageResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); + asyncContext.onComplete(responseEventMeshCommand); + return; + } + + String bizNo = Objects.requireNonNull(event.getExtension(SendMessageRequestBody.BIZSEQNO)).toString(); + String uniqueId = Objects.requireNonNull(event.getExtension(SendMessageRequestBody.UNIQUEID)).toString(); + String producerGroup = Objects.requireNonNull(event.getExtension(SendMessageRequestBody.PRODUCERGROUP)).toString(); + String topic = event.getSubject(); + //validate body - if (StringUtils.isBlank(sendMessageRequestBody.getBizSeqNo()) - || StringUtils.isBlank(sendMessageRequestBody.getUniqueId()) - || StringUtils.isBlank(sendMessageRequestBody.getProducerGroup()) - || StringUtils.isBlank(sendMessageRequestBody.getTopic()) - || StringUtils.isBlank(sendMessageRequestBody.getContent()) - || (StringUtils.isBlank(sendMessageRequestBody.getTtl()))) { - //sync message TTL can't be empty + if (StringUtils.isBlank(bizNo) + || StringUtils.isBlank(uniqueId) + || StringUtils.isBlank(producerGroup) + || StringUtils.isBlank(topic) + || event.getData() == null) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( sendMessageResponseHeader, SendMessageResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getErrMsg())); @@ -111,11 +142,10 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext //do acl check if(eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshServerSecurityEnable) { String remoteAddr = RemotingHelper.parseChannelRemoteAddr(ctx.channel()); - String user = sendMessageRequestHeader.getUsername(); - String pass = sendMessageRequestHeader.getPasswd(); - String subsystem = sendMessageRequestHeader.getSys(); - int requestCode = Integer.valueOf(sendMessageRequestHeader.getCode()); - String topic = sendMessageRequestBody.getTopic(); + String user = event.getExtension(ProtocolKey.ClientInstanceKey.USERNAME).toString(); + String pass = event.getExtension(ProtocolKey.ClientInstanceKey.PASSWD).toString(); + String subsystem = event.getExtension(ProtocolKey.ClientInstanceKey.SYS).toString(); + int requestCode = Integer.parseInt(asyncContext.getRequest().getRequestCode()); try { Acl.doAclCheckInHttpSend(remoteAddr, user, pass, subsystem, topic, requestCode); }catch (Exception e){ @@ -142,7 +172,6 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext return; } - String producerGroup = sendMessageRequestBody.getProducerGroup(); EventMeshProducer eventMeshProducer = eventMeshHTTPServer.getProducerManager().getEventMeshProducer(producerGroup); if (!eventMeshProducer.getStarted().get()) { @@ -154,40 +183,43 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext } String ttl = String.valueOf(EventMeshConstants.DEFAULT_MSG_TTL_MILLS); - if (StringUtils.isNotBlank(sendMessageRequestBody.getTtl()) && StringUtils.isNumeric(sendMessageRequestBody.getTtl())) { - ttl = sendMessageRequestBody.getTtl(); + if (StringUtils.isBlank(event.getExtension(SendMessageRequestBody.TTL).toString()) + && !StringUtils.isNumeric(event.getExtension(SendMessageRequestBody.TTL).toString())) { + event = CloudEventBuilder.from(event).withExtension(SendMessageRequestBody.TTL, ttl).build(); } - Message omsMsg = new Message(); try { // body - omsMsg.setBody(sendMessageRequestBody.getContent().getBytes(EventMeshConstants.DEFAULT_CHARSET)); - // topic - omsMsg.setTopic(sendMessageRequestBody.getTopic()); - omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION, sendMessageRequestBody.getTopic()); - - if (!StringUtils.isBlank(sendMessageRequestBody.getTag())) { - omsMsg.putUserProperties(EventMeshConstants.TAG, sendMessageRequestBody.getTag()); - } +// omsMsg.setBody(sendMessageRequestBody.getContent().getBytes(EventMeshConstants.DEFAULT_CHARSET)); +// // topic +// omsMsg.setTopic(sendMessageRequestBody.getTopic()); +// omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION, sendMessageRequestBody.getTopic()); +// +// if (!StringUtils.isBlank(sendMessageRequestBody.getTag())) { +// omsMsg.putUserProperties(EventMeshConstants.TAG, sendMessageRequestBody.getTag()); +// } // ttl - omsMsg.putUserProperties(Constants.PROPERTY_MESSAGE_TIMEOUT, ttl); - // bizNo - omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_SEARCH_KEYS, sendMessageRequestBody.getBizSeqNo()); - omsMsg.putUserProperties("msgType", "persistent"); - omsMsg.putUserProperties(EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())); - omsMsg.putUserProperties(Constants.RMB_UNIQ_ID, sendMessageRequestBody.getUniqueId()); - omsMsg.putUserProperties(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, String.valueOf(System.currentTimeMillis())); +// omsMsg.putUserProperties(Constants.PROPERTY_MESSAGE_TIMEOUT, ttl); +// // bizNo +// omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_SEARCH_KEYS, sendMessageRequestBody.getBizSeqNo()); + event = CloudEventBuilder.from(event) + .withExtension("msgtype", "persistent") + .withExtension(EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .withExtension(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .build(); +// omsMsg.putUserProperties("msgType", "persistent"); +// omsMsg.putUserProperties(EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())); +// omsMsg.putUserProperties(Constants.RMB_UNIQ_ID, sendMessageRequestBody.getUniqueId()); +// omsMsg.putUserProperties(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, String.valueOf(System.currentTimeMillis())); // new rocketmq client can't support put DeFiBusConstant.PROPERTY_MESSAGE_TTL // rocketMQMsg.putUserProperty(DeFiBusConstant.PROPERTY_MESSAGE_TTL, ttl); if (messageLogger.isDebugEnabled()) { - messageLogger.debug("msg2MQMsg suc, bizSeqNo={}, topic={}", sendMessageRequestBody.getBizSeqNo(), - sendMessageRequestBody.getTopic()); + messageLogger.debug("msg2MQMsg suc, bizSeqNo={}, topic={}", bizNo, topic); } } catch (Exception e) { - messageLogger.error("msg2MQMsg err, bizSeqNo={}, topic={}", sendMessageRequestBody.getBizSeqNo(), - sendMessageRequestBody.getTopic(), e); + messageLogger.error("msg2MQMsg err, bizSeqNo={}, topic={}", bizNo, topic, e); responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( sendMessageResponseHeader, SendMessageResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PACKAGE_MSG_ERR.getRetCode(), EventMeshRetCode.EVENTMESH_PACKAGE_MSG_ERR.getErrMsg() + EventMeshUtil.stackTrace(e, 2))); @@ -195,7 +227,7 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext return; } - final SendMessageContext sendMessageContext = new SendMessageContext(sendMessageRequestBody.getBizSeqNo(), omsMsg, eventMeshProducer, eventMeshHTTPServer); + final SendMessageContext sendMessageContext = new SendMessageContext(bizNo, event, eventMeshProducer, eventMeshHTTPServer); eventMeshHTTPServer.metrics.summaryMetrics.recordSendMsg(); long startTime = System.currentTimeMillis(); @@ -214,13 +246,12 @@ public void onResponse(HttpCommand httpCommand) { } }; - LiteMessage liteMessage = new LiteMessage(sendMessageRequestBody.getBizSeqNo(), - sendMessageRequestBody.getUniqueId(), sendMessageRequestBody.getTopic(), - sendMessageRequestBody.getContent()) - .setProp(sendMessageRequestBody.getExtFields()); try { - sendMessageContext.getMsg().getUserProperties().put(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, String.valueOf(System.currentTimeMillis())); + event = CloudEventBuilder.from(sendMessageContext.getEvent()) + .withExtension(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .build(); + sendMessageContext.setEvent(event); eventMeshProducer.send(sendMessageContext, new SendCallback() { @Override @@ -232,10 +263,7 @@ public void onSuccess(SendResult sendResult) { long endTime = System.currentTimeMillis(); eventMeshHTTPServer.metrics.summaryMetrics.recordSendMsgCost(endTime - startTime); messageLogger.info("message|eventMesh2mq|REQ|ASYNC|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", - endTime - startTime, - sendMessageRequestBody.getTopic(), - sendMessageRequestBody.getBizSeqNo(), - sendMessageRequestBody.getUniqueId()); + endTime - startTime, topic, bizNo, uniqueId); } @Override @@ -251,10 +279,7 @@ public void onException(OnExceptionContext context) { eventMeshHTTPServer.metrics.summaryMetrics.recordSendMsgFailed(); eventMeshHTTPServer.metrics.summaryMetrics.recordSendMsgCost(endTime - startTime); messageLogger.error("message|eventMesh2mq|REQ|ASYNC|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", - endTime - startTime, - sendMessageRequestBody.getTopic(), - sendMessageRequestBody.getBizSeqNo(), - sendMessageRequestBody.getUniqueId(), context.getException()); + endTime - startTime, topic, bizNo, uniqueId, context.getException()); } }); } catch (Exception ex) { @@ -267,10 +292,7 @@ public void onException(OnExceptionContext context) { eventMeshHTTPServer.getHttpRetryer().pushRetry(sendMessageContext.delay(10000)); long endTime = System.currentTimeMillis(); messageLogger.error("message|eventMesh2mq|REQ|ASYNC|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", - endTime - startTime, - sendMessageRequestBody.getTopic(), - sendMessageRequestBody.getBizSeqNo(), - sendMessageRequestBody.getUniqueId(), ex); + endTime - startTime, topic, bizNo, uniqueId, ex); eventMeshHTTPServer.metrics.summaryMetrics.recordSendMsgFailed(); eventMeshHTTPServer.metrics.summaryMetrics.recordSendMsgCost(endTime - startTime); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendSyncMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendSyncMessageProcessor.java index 79f391eab5..dff902ab5d 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendSyncMessageProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendSyncMessageProcessor.java @@ -17,18 +17,22 @@ package org.apache.eventmesh.runtime.core.protocol.http.processor; -import org.apache.eventmesh.api.RRCallback; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.LiteMessage; -import org.apache.eventmesh.common.command.HttpCommand; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; + +import org.apache.eventmesh.api.RequestReplyCallback; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; import org.apache.eventmesh.common.protocol.http.common.RequestCode; -import org.apache.eventmesh.common.protocol.http.header.message.SendMessageRequestHeader; import org.apache.eventmesh.common.protocol.http.header.message.SendMessageResponseHeader; import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.acl.Acl; import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; import org.apache.eventmesh.runtime.constants.EventMeshConstants; @@ -38,18 +42,17 @@ import org.apache.eventmesh.runtime.core.protocol.http.producer.EventMeshProducer; import org.apache.eventmesh.runtime.core.protocol.http.producer.SendMessageContext; import org.apache.eventmesh.runtime.util.EventMeshUtil; -import org.apache.eventmesh.runtime.util.OMSUtil; import org.apache.eventmesh.runtime.util.RemotingHelper; import org.apache.commons.lang3.StringUtils; +import java.util.Objects; import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import io.netty.channel.ChannelHandlerContext; -import io.openmessaging.api.Message; public class SendSyncMessageProcessor implements HttpRequestProcessor { @@ -76,25 +79,26 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", RequestCode.get(Integer.valueOf(asyncContext.getRequest().getRequestCode())), EventMeshConstants.PROTOCOL_HTTP, - RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtil.getLocalAddress()); + RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtils.getLocalAddress()); - SendMessageRequestHeader sendMessageRequestHeader = - (SendMessageRequestHeader) asyncContext.getRequest().getHeader(); - SendMessageRequestBody sendMessageRequestBody = - (SendMessageRequestBody) asyncContext.getRequest().getBody(); + ProtocolAdaptor httpCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor("cloudevents"); + CloudEvent event = httpCommandProtocolAdaptor.toCloudEvent(asyncContext.getRequest()); SendMessageResponseHeader sendMessageResponseHeader = SendMessageResponseHeader .buildHeader(Integer.valueOf(asyncContext.getRequest().getRequestCode()), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshCluster, - IPUtil.getLocalAddress(), + IPUtils.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshIDC); - if (StringUtils.isBlank(sendMessageRequestHeader.getIdc()) - || StringUtils.isBlank(sendMessageRequestHeader.getPid()) - || !StringUtils.isNumeric(sendMessageRequestHeader.getPid()) - || StringUtils.isBlank(sendMessageRequestHeader.getSys())) { + //validate event + if (event == null + || StringUtils.isBlank(event.getId()) + || event.getSource() == null + || event.getSpecVersion() == null + || StringUtils.isBlank(event.getType()) + || StringUtils.isBlank(event.getSubject())) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( sendMessageResponseHeader, SendMessageResponseBody @@ -104,12 +108,45 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext return; } - if (StringUtils.isBlank(sendMessageRequestBody.getBizSeqNo()) - || StringUtils.isBlank(sendMessageRequestBody.getUniqueId()) - || StringUtils.isBlank(sendMessageRequestBody.getProducerGroup()) - || StringUtils.isBlank(sendMessageRequestBody.getTopic()) - || StringUtils.isBlank(sendMessageRequestBody.getContent()) - || (StringUtils.isBlank(sendMessageRequestBody.getTtl()))) { + String idc = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.IDC)) + .toString(); + String pid = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.PID)) + .toString(); + String sys = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.SYS)) + .toString(); + + //validate event-extension + if (StringUtils.isBlank(idc) + || StringUtils.isBlank(pid) + || !StringUtils.isNumeric(pid) + || StringUtils.isBlank(sys)) { + responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( + sendMessageResponseHeader, + SendMessageResponseBody + .buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); + asyncContext.onComplete(responseEventMeshCommand); + return; + } + + String bizNo = + Objects.requireNonNull(event.getExtension(SendMessageRequestBody.BIZSEQNO)).toString(); + String uniqueId = + Objects.requireNonNull(event.getExtension(SendMessageRequestBody.UNIQUEID)).toString(); + String producerGroup = + Objects.requireNonNull(event.getExtension(SendMessageRequestBody.PRODUCERGROUP)) + .toString(); + String topic = event.getSubject(); + String ttl = + Objects.requireNonNull(event.getExtension(SendMessageRequestBody.TTL)).toString(); + + //validate body + if (StringUtils.isBlank(bizNo) + || StringUtils.isBlank(uniqueId) + || StringUtils.isBlank(producerGroup) + || StringUtils.isBlank(topic) + || event.getData() == null + || StringUtils.isBlank(ttl)) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( sendMessageResponseHeader, SendMessageResponseBody @@ -122,13 +159,12 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext //do acl check if (eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshServerSecurityEnable) { String remoteAddr = RemotingHelper.parseChannelRemoteAddr(ctx.channel()); - String user = sendMessageRequestHeader.getUsername(); - String pass = sendMessageRequestHeader.getPasswd(); - String subsystem = sendMessageRequestHeader.getSys(); - int requestCode = Integer.valueOf(sendMessageRequestHeader.getCode()); - String topic = sendMessageRequestBody.getTopic(); + String user = event.getExtension(ProtocolKey.ClientInstanceKey.USERNAME).toString(); + String pass = event.getExtension(ProtocolKey.ClientInstanceKey.PASSWD).toString(); + int requestCode = Integer.parseInt(asyncContext.getRequest().getRequestCode()); + try { - Acl.doAclCheckInHttpSend(remoteAddr, user, pass, subsystem, topic, requestCode); + Acl.doAclCheckInHttpSend(remoteAddr, user, pass, sys, topic, requestCode); } catch (Exception e) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( @@ -156,7 +192,6 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext return; } - String producerGroup = sendMessageRequestBody.getProducerGroup(); EventMeshProducer eventMeshProducer = eventMeshHTTPServer.getProducerManager().getEventMeshProducer(producerGroup); @@ -170,45 +205,19 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext return; } - String ttl = String.valueOf(EventMeshConstants.DEFAULT_MSG_TTL_MILLS); - if (StringUtils.isNotBlank(sendMessageRequestBody.getTtl()) - && StringUtils.isNumeric(sendMessageRequestBody.getTtl())) { - ttl = sendMessageRequestBody.getTtl(); - } - - Message omsMsg = new Message(); try { - // body - omsMsg.setBody( - sendMessageRequestBody.getContent().getBytes(EventMeshConstants.DEFAULT_CHARSET)); - // topic - omsMsg.setTopic(sendMessageRequestBody.getTopic()); - omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION, - sendMessageRequestBody.getTopic()); - if (!StringUtils.isBlank(sendMessageRequestBody.getTag())) { - omsMsg.putUserProperties("Tag", sendMessageRequestBody.getTag()); - } - // ttl - omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_TIMEOUT, ttl); - // bizNo - omsMsg.putSystemProperties(Constants.PROPERTY_MESSAGE_SEARCH_KEYS, - sendMessageRequestBody.getBizSeqNo()); - omsMsg.putUserProperties("msgType", "persistent"); - omsMsg.putUserProperties(EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP, - String.valueOf(System.currentTimeMillis())); - omsMsg.putUserProperties(Constants.RMB_UNIQ_ID, sendMessageRequestBody.getUniqueId()); + event = CloudEventBuilder.from(event) + .withExtension("msgtype", "persistent") + .withExtension(EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .withExtension(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .build(); if (messageLogger.isDebugEnabled()) { - messageLogger.debug("msg2MQMsg suc, bizSeqNo={}, topic={}", - sendMessageRequestBody.getBizSeqNo(), - sendMessageRequestBody.getTopic()); + messageLogger.debug("msg2MQMsg suc, bizSeqNo={}, topic={}", bizNo, topic); } - omsMsg.putUserProperties(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, - String.valueOf(System.currentTimeMillis())); + } catch (Exception e) { - messageLogger - .error("msg2MQMsg err, bizSeqNo={}, topic={}", sendMessageRequestBody.getBizSeqNo(), - sendMessageRequestBody.getTopic(), e); + messageLogger.error("msg2MQMsg err, bizSeqNo={}, topic={}", bizNo, topic, e); responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( sendMessageResponseHeader, SendMessageResponseBody @@ -220,7 +229,7 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext } final SendMessageContext sendMessageContext = - new SendMessageContext(sendMessageRequestBody.getBizSeqNo(), omsMsg, eventMeshProducer, + new SendMessageContext(bizNo, event, eventMeshProducer, eventMeshHTTPServer); eventMeshHTTPServer.metrics.summaryMetrics.recordSendMsg(); @@ -242,42 +251,33 @@ public void onResponse(HttpCommand httpCommand) { } }; - LiteMessage liteMessage = new LiteMessage(sendMessageRequestBody.getBizSeqNo(), - sendMessageRequestBody.getUniqueId(), sendMessageRequestBody.getTopic(), - sendMessageRequestBody.getContent()) - .setProp(sendMessageRequestBody.getExtFields()); try { - eventMeshProducer.request(sendMessageContext, new RRCallback() { + eventMeshProducer.request(sendMessageContext, new RequestReplyCallback() { @Override - public void onSuccess(Message omsMsg) { - omsMsg.getUserProperties().put(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP, - omsMsg.getSystemProperties("BORN_TIMESTAMP")); - omsMsg.getUserProperties().put(EventMeshConstants.STORE_TIMESTAMP, - omsMsg.getSystemProperties("STORE_TIMESTAMP")); - omsMsg.getUserProperties().put(EventMeshConstants.RSP_MQ2EVENTMESH_TIMESTAMP, - String.valueOf(System.currentTimeMillis())); - messageLogger.info( - "message|mq2eventMesh|RSP|SYNC|rrCost={}ms|topic={}" + public void onSuccess(CloudEvent event) { + messageLogger.info("message|mq2eventMesh|RSP|SYNC|rrCost={}ms|topic={}" + "|bizSeqNo={}|uniqueId={}", System.currentTimeMillis() - startTime, - sendMessageRequestBody.getTopic(), - sendMessageRequestBody.getBizSeqNo(), - sendMessageRequestBody.getUniqueId()); + topic, bizNo, uniqueId); try { - final String rtnMsg = - new String(omsMsg.getBody(), EventMeshConstants.DEFAULT_CHARSET); - omsMsg.getUserProperties().put(EventMeshConstants.RSP_EVENTMESH2C_TIMESTAMP, - String.valueOf(System.currentTimeMillis())); + event = CloudEventBuilder.from(event) + .withExtension(EventMeshConstants.RSP_EVENTMESH2C_TIMESTAMP, + String.valueOf(System.currentTimeMillis())) + .withExtension(EventMeshConstants.RSP_MQ2EVENTMESH_TIMESTAMP, + String.valueOf(System.currentTimeMillis())) + .build(); + final String rtnMsg = new String(event.getData().toBytes(), + EventMeshConstants.DEFAULT_CHARSET); + HttpCommand succ = asyncContext.getRequest().createHttpCommandResponse( sendMessageResponseHeader, SendMessageResponseBody.buildBody(EventMeshRetCode.SUCCESS.getRetCode(), - JsonUtils.serialize(new SendMessageResponseBody.ReplyMessage(omsMsg - .getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION), - rtnMsg, - OMSUtil.combineProp(omsMsg.getSystemProperties(), - omsMsg.getUserProperties())) - ))); + JsonUtils.serialize(SendMessageResponseBody.ReplyMessage.builder() + .topic(topic) + .body(rtnMsg) + .properties(EventMeshUtil.getEventProp(event)) + .build()))); asyncContext.onComplete(succ, handler); } catch (Exception ex) { HttpCommand err = asyncContext.getRequest().createHttpCommandResponse( @@ -305,11 +305,9 @@ public void onException(Throwable e) { messageLogger.error( "message|mq2eventMesh|RSP|SYNC|rrCost={}ms|topic={}" + "|bizSeqNo={}|uniqueId={}", System.currentTimeMillis() - startTime, - sendMessageRequestBody.getTopic(), - sendMessageRequestBody.getBizSeqNo(), - sendMessageRequestBody.getUniqueId(), e); + topic, bizNo, uniqueId, e); } - }, Integer.valueOf(ttl)); + }, Integer.parseInt(ttl)); } catch (Exception ex) { HttpCommand err = asyncContext.getRequest().createHttpCommandResponse( sendMessageResponseHeader, @@ -325,10 +323,7 @@ public void onException(Throwable e) { eventMeshHTTPServer.metrics.summaryMetrics.recordSendMsgCost(endTime - startTime); messageLogger.error( "message|eventMesh2mq|REQ|SYNC|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", - endTime - startTime, - sendMessageRequestBody.getTopic(), - sendMessageRequestBody.getBizSeqNo(), - sendMessageRequestBody.getUniqueId(), ex); + endTime - startTime, topic, bizNo, uniqueId, ex); } return; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SubscribeProcessor.java index d91b462b64..0c75e7ab03 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SubscribeProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SubscribeProcessor.java @@ -17,8 +17,8 @@ package org.apache.eventmesh.runtime.core.protocol.http.processor; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.command.HttpCommand; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.SubscriptionItem; import org.apache.eventmesh.common.protocol.http.body.client.SubscribeRequestBody; import org.apache.eventmesh.common.protocol.http.body.client.SubscribeResponseBody; @@ -70,22 +70,24 @@ public SubscribeProcessor(EventMeshHTTPServer eventMeshHTTPServer) { @Override public void processRequest(ChannelHandlerContext ctx, AsyncContext asyncContext) - throws Exception { + throws Exception { HttpCommand responseEventMeshCommand; + final HttpCommand request = asyncContext.getRequest(); + final Integer requestCode = Integer.valueOf(asyncContext.getRequest().getRequestCode()); + httpLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", - RequestCode.get(Integer.valueOf(asyncContext.getRequest().getRequestCode())), + RequestCode.get(requestCode), EventMeshConstants.PROTOCOL_HTTP, - RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtil.getLocalAddress()); - SubscribeRequestHeader subscribeRequestHeader = - (SubscribeRequestHeader) asyncContext.getRequest().getHeader(); - SubscribeRequestBody subscribeRequestBody = - (SubscribeRequestBody) asyncContext.getRequest().getBody(); + RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtils.getLocalAddress() + ); + SubscribeRequestHeader subscribeRequestHeader = (SubscribeRequestHeader) request.getHeader(); + SubscribeRequestBody subscribeRequestBody = (SubscribeRequestBody) request.getBody(); SubscribeResponseHeader subscribeResponseHeader = SubscribeResponseHeader - .buildHeader(Integer.valueOf(asyncContext.getRequest().getRequestCode()), + .buildHeader(requestCode, eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshCluster, - IPUtil.getLocalAddress(), + IPUtils.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshIDC); @@ -94,7 +96,7 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext || StringUtils.isBlank(subscribeRequestHeader.getPid()) || !StringUtils.isNumeric(subscribeRequestHeader.getPid()) || StringUtils.isBlank(subscribeRequestHeader.getSys())) { - responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( + responseEventMeshCommand = request.createHttpCommandResponse( subscribeResponseHeader, SubscribeResponseBody .buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), @@ -105,10 +107,10 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext //validate body if (StringUtils.isBlank(subscribeRequestBody.getUrl()) - || CollectionUtils.isEmpty(subscribeRequestBody.getTopics()) - || StringUtils.isBlank(subscribeRequestBody.getConsumerGroup())) { + || CollectionUtils.isEmpty(subscribeRequestBody.getTopics()) + || StringUtils.isBlank(subscribeRequestBody.getConsumerGroup())) { - responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( + responseEventMeshCommand = request.createHttpCommandResponse( subscribeResponseHeader, SubscribeResponseBody .buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR.getRetCode(), @@ -124,21 +126,20 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext String user = subscribeRequestHeader.getUsername(); String pass = subscribeRequestHeader.getPasswd(); String subsystem = subscribeRequestHeader.getSys(); - int requestCode = Integer.valueOf(subscribeRequestHeader.getCode()); for (SubscriptionItem item : subTopicList) { try { Acl.doAclCheckInHttpReceive(remoteAddr, user, pass, subsystem, item.getTopic(), - requestCode); + requestCode); } catch (Exception e) { responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - subscribeResponseHeader, - SendMessageResponseBody - .buildBody(EventMeshRetCode.EVENTMESH_ACL_ERR.getRetCode(), - e.getMessage())); + subscribeResponseHeader, + SendMessageResponseBody + .buildBody(EventMeshRetCode.EVENTMESH_ACL_ERR.getRetCode(), + e.getMessage())); asyncContext.onComplete(responseEventMeshCommand); aclLogger - .warn("CLIENT HAS NO PERMISSION,SubscribeProcessor subscribe failed", e); + .warn("CLIENT HAS NO PERMISSION,SubscribeProcessor subscribe failed", e); return; } } @@ -153,7 +154,7 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext for (SubscriptionItem subTopic : subTopicList) { List groupTopicClients = eventMeshHTTPServer.localClientInfoMapping - .get(consumerGroup + "@" + subTopic.getTopic()); + .get(consumerGroup + "@" + subTopic.getTopic()); if (CollectionUtils.isEmpty(groupTopicClients)) { httpLogger.error("group {} topic {} clients is empty", consumerGroup, subTopic); @@ -170,7 +171,7 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext } } ConsumerGroupConf consumerGroupConf = - eventMeshHTTPServer.localConsumerGroupMapping.get(consumerGroup); + eventMeshHTTPServer.localConsumerGroupMapping.get(consumerGroup); if (consumerGroupConf == null) { // new subscription consumerGroupConf = new ConsumerGroupConf(consumerGroup); @@ -188,7 +189,17 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext } else { // already subscribed Map map = - consumerGroupConf.getConsumerGroupTopicConf(); + consumerGroupConf.getConsumerGroupTopicConf(); + if (!map.containsKey(subTopic.getTopic())) { + //If there are multiple topics, append it + ConsumerGroupTopicConf newTopicConf = new ConsumerGroupTopicConf(); + newTopicConf.setConsumerGroup(consumerGroup); + newTopicConf.setTopic(subTopic.getTopic()); + newTopicConf.setSubscriptionItem(subTopic); + newTopicConf.setUrls(new HashSet<>(Arrays.asList(url))); + newTopicConf.setIdcUrls(idcUrls); + map.put(subTopic.getTopic(), newTopicConf); + } for (String key : map.keySet()) { if (StringUtils.equals(subTopic.getTopic(), key)) { ConsumerGroupTopicConf latestTopicConf = new ConsumerGroupTopicConf(); @@ -202,15 +213,6 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext latestTopicConf.setIdcUrls(idcUrls); map.put(key, latestTopicConf); - } else { - //If there are multiple topics, append it - ConsumerGroupTopicConf newTopicConf = new ConsumerGroupTopicConf(); - newTopicConf.setConsumerGroup(consumerGroup); - newTopicConf.setTopic(subTopic.getTopic()); - newTopicConf.setSubscriptionItem(subTopic); - newTopicConf.setUrls(new HashSet<>(Arrays.asList(url))); - newTopicConf.setIdcUrls(idcUrls); - map.put(subTopic.getTopic(), newTopicConf); } } } @@ -221,7 +223,7 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext try { // subscription relationship change notification eventMeshHTTPServer.getConsumerManager().notifyConsumerManager(consumerGroup, - eventMeshHTTPServer.localConsumerGroupMapping.get(consumerGroup)); + eventMeshHTTPServer.localConsumerGroupMapping.get(consumerGroup)); final CompleteHandler handler = new CompleteHandler() { @Override @@ -232,31 +234,29 @@ public void onResponse(HttpCommand httpCommand) { } eventMeshHTTPServer.sendResponse(ctx, httpCommand.httpResponse()); eventMeshHTTPServer.metrics.summaryMetrics.recordHTTPReqResTimeCost( - System.currentTimeMillis() - - asyncContext.getRequest().getReqTime()); + System.currentTimeMillis() - request.getReqTime()); } catch (Exception ex) { // ignore } } }; - responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - EventMeshRetCode.SUCCESS.getRetCode(), EventMeshRetCode.SUCCESS.getErrMsg()); + responseEventMeshCommand = request.createHttpCommandResponse(EventMeshRetCode.SUCCESS); asyncContext.onComplete(responseEventMeshCommand, handler); } catch (Exception e) { HttpCommand err = asyncContext.getRequest().createHttpCommandResponse( - subscribeResponseHeader, - SubscribeResponseBody - .buildBody(EventMeshRetCode.EVENTMESH_SUBSCRIBE_ERR.getRetCode(), - EventMeshRetCode.EVENTMESH_SUBSCRIBE_ERR.getErrMsg() - + EventMeshUtil.stackTrace(e, 2))); + subscribeResponseHeader, + SubscribeResponseBody + .buildBody(EventMeshRetCode.EVENTMESH_SUBSCRIBE_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_SUBSCRIBE_ERR.getErrMsg() + + EventMeshUtil.stackTrace(e, 2))); asyncContext.onComplete(err); long endTime = System.currentTimeMillis(); httpLogger.error( - "message|eventMesh2mq|REQ|ASYNC|send2MQCost={}ms|topic={}" - + "|bizSeqNo={}|uniqueId={}", endTime - startTime, - JsonUtils.serialize(subscribeRequestBody.getTopics()), - subscribeRequestBody.getUrl(), e); + "message|eventMesh2mq|REQ|ASYNC|send2MQCost={}ms|topic={}" + + "|bizSeqNo={}|uniqueId={}", endTime - startTime, + JsonUtils.serialize(subscribeRequestBody.getTopics()), + subscribeRequestBody.getUrl(), e); eventMeshHTTPServer.metrics.summaryMetrics.recordSendMsgFailed(); eventMeshHTTPServer.metrics.summaryMetrics.recordSendMsgCost(endTime - startTime); } @@ -286,7 +286,7 @@ private void registerClient(SubscribeRequestHeader subscribeRequestHeader, Strin if (eventMeshHTTPServer.localClientInfoMapping.containsKey(groupTopicKey)) { List localClients = - eventMeshHTTPServer.localClientInfoMapping.get(groupTopicKey); + eventMeshHTTPServer.localClientInfoMapping.get(groupTopicKey); boolean isContains = false; for (Client localClient : localClients) { if (StringUtils.equals(localClient.url, client.url)) { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/UnSubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/UnSubscribeProcessor.java index df3921dd9b..7d9eb87e1a 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/UnSubscribeProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/UnSubscribeProcessor.java @@ -17,8 +17,8 @@ package org.apache.eventmesh.runtime.core.protocol.http.processor; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.command.HttpCommand; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.http.body.client.UnSubscribeRequestBody; import org.apache.eventmesh.common.protocol.http.body.client.UnSubscribeResponseBody; import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; @@ -71,7 +71,7 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext httpLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", RequestCode.get(Integer.valueOf(asyncContext.getRequest().getRequestCode())), EventMeshConstants.PROTOCOL_HTTP, - RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtil.getLocalAddress()); + RemotingHelper.parseChannelRemoteAddr(ctx.channel()), IPUtils.getLocalAddress()); UnSubscribeRequestHeader unSubscribeRequestHeader = (UnSubscribeRequestHeader) asyncContext.getRequest().getHeader(); UnSubscribeRequestBody unSubscribeRequestBody = @@ -81,7 +81,7 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext UnSubscribeResponseHeader .buildHeader(Integer.valueOf(asyncContext.getRequest().getRequestCode()), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshCluster, - IPUtil.getLocalAddress(), + IPUtils.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshIDC); @@ -208,9 +208,8 @@ public void onResponse(HttpCommand httpCommand) { eventMeshHTTPServer.getConsumerManager().notifyConsumerManager(consumerGroup, eventMeshHTTPServer.localConsumerGroupMapping.get(consumerGroup)); - responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - EventMeshRetCode.SUCCESS.getRetCode(), - EventMeshRetCode.SUCCESS.getErrMsg()); + responseEventMeshCommand = + asyncContext.getRequest().createHttpCommandResponse(EventMeshRetCode.SUCCESS); asyncContext.onComplete(responseEventMeshCommand, handler); } catch (Exception e) { @@ -236,9 +235,8 @@ public void onResponse(HttpCommand httpCommand) { try { eventMeshHTTPServer.getConsumerManager() .notifyConsumerManager(consumerGroup, null); - responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( - EventMeshRetCode.SUCCESS.getRetCode(), - EventMeshRetCode.SUCCESS.getErrMsg()); + responseEventMeshCommand = + asyncContext.getRequest().createHttpCommandResponse(EventMeshRetCode.SUCCESS); asyncContext.onComplete(responseEventMeshCommand, handler); // clean ClientInfo eventMeshHTTPServer.localClientInfoMapping.keySet() diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/inf/HttpRequestProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/inf/HttpRequestProcessor.java index cafddac0ff..4f256d66e5 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/inf/HttpRequestProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/inf/HttpRequestProcessor.java @@ -19,7 +19,7 @@ import io.netty.channel.ChannelHandlerContext; -import org.apache.eventmesh.common.command.HttpCommand; +import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.runtime.core.protocol.http.async.AsyncContext; public interface HttpRequestProcessor { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/EventMeshProducer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/EventMeshProducer.java index a058c9bcd1..34c8d7d5d2 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/EventMeshProducer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/EventMeshProducer.java @@ -20,10 +20,8 @@ import java.util.Properties; import java.util.concurrent.atomic.AtomicBoolean; -import io.openmessaging.api.Message; -import io.openmessaging.api.SendCallback; - -import org.apache.eventmesh.api.RRCallback; +import org.apache.eventmesh.api.RequestReplyCallback; +import org.apache.eventmesh.api.SendCallback; import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; import org.apache.eventmesh.runtime.core.consumergroup.ProducerGroupConf; import org.apache.eventmesh.runtime.core.plugin.MQProducerWrapper; @@ -52,16 +50,16 @@ public AtomicBoolean getStarted() { protected EventMeshHTTPConfiguration eventMeshHttpConfiguration; public void send(SendMessageContext sendMsgContext, SendCallback sendCallback) throws Exception { - mqProducerWrapper.send(sendMsgContext.getMsg(), sendCallback); + mqProducerWrapper.send(sendMsgContext.getEvent(), sendCallback); } - public void request(SendMessageContext sendMsgContext, RRCallback rrCallback, long timeout) + public void request(SendMessageContext sendMsgContext, RequestReplyCallback rrCallback, long timeout) throws Exception { - mqProducerWrapper.request(sendMsgContext.getMsg(), rrCallback, timeout); + mqProducerWrapper.request(sendMsgContext.getEvent(), rrCallback, timeout); } public boolean reply(final SendMessageContext sendMsgContext, final SendCallback sendCallback) throws Exception { - mqProducerWrapper.reply(sendMsgContext.getMsg(), sendCallback); + mqProducerWrapper.reply(sendMsgContext.getEvent(), sendCallback); return true; } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/SendMessageContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/SendMessageContext.java index be368b4386..8569951014 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/SendMessageContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/SendMessageContext.java @@ -21,12 +21,12 @@ import java.util.List; import java.util.Map; -import io.openmessaging.api.Message; -import io.openmessaging.api.OnExceptionContext; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; +import io.cloudevents.CloudEvent; import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; import org.apache.eventmesh.runtime.core.protocol.http.retry.RetryContext; @@ -37,7 +37,7 @@ public class SendMessageContext extends RetryContext { public static Logger logger = LoggerFactory.getLogger("retry"); - private Message msg; + private CloudEvent event; private String bizSeqNo; @@ -49,11 +49,11 @@ public class SendMessageContext extends RetryContext { public EventMeshHTTPServer eventMeshHTTPServer; - private List messageList; + private List eventList; - public SendMessageContext(String bizSeqNo, Message msg, EventMeshProducer eventMeshProducer, EventMeshHTTPServer eventMeshHTTPServer) { + public SendMessageContext(String bizSeqNo, CloudEvent event, EventMeshProducer eventMeshProducer, EventMeshHTTPServer eventMeshHTTPServer) { this.bizSeqNo = bizSeqNo; - this.msg = msg; + this.event = event; this.eventMeshProducer = eventMeshProducer; this.eventMeshHTTPServer = eventMeshHTTPServer; } @@ -77,12 +77,12 @@ public void setBizSeqNo(String bizSeqNo) { this.bizSeqNo = bizSeqNo; } - public Message getMsg() { - return msg; + public CloudEvent getEvent() { + return event; } - public void setMsg(Message msg) { - this.msg = msg; + public void setEvent(CloudEvent event) { + this.event = event; } public EventMeshProducer getEventMeshProducer() { @@ -101,12 +101,12 @@ public void setCreateTime(long createTime) { this.createTime = createTime; } - public List getMessageList() { - return messageList; + public List getEventList() { + return eventList; } - public void setMessageList(List messageList) { - this.messageList = messageList; + public void setEventList(List eventList) { + this.eventList = eventList; } @Override diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/AsyncHTTPPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/AsyncHTTPPushRequest.java index e0e03495ee..43750ad446 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/AsyncHTTPPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/AsyncHTTPPushRequest.java @@ -17,9 +17,13 @@ package org.apache.eventmesh.runtime.core.protocol.http.push; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.RandomStringUtil; +import org.apache.eventmesh.common.protocol.http.HttpCommand; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.utils.RandomStringUtils; import org.apache.eventmesh.common.exception.JsonException; import org.apache.eventmesh.common.protocol.SubscriptionType; import org.apache.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; @@ -28,9 +32,11 @@ import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; import org.apache.eventmesh.common.protocol.http.common.RequestCode; import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.http.consumer.HandleMsgContext; -import org.apache.eventmesh.runtime.util.OMSUtil; +import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; @@ -44,12 +50,9 @@ import org.apache.http.util.EntityUtils; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.nio.charset.StandardCharsets; +import java.util.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -100,20 +103,27 @@ public void tryHTTPRequest() { builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHCLUSTER, handleMsgContext.getEventMeshHTTPServer() .getEventMeshHttpConfiguration().eventMeshCluster); - builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIP, IPUtil.getLocalAddress()); + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIP, IPUtils.getLocalAddress()); builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHENV, handleMsgContext.getEventMeshHTTPServer().getEventMeshHttpConfiguration().eventMeshEnv); builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIDC, handleMsgContext.getEventMeshHTTPServer().getEventMeshHttpConfiguration().eventMeshIDC); - handleMsgContext.getMsg().getUserProperties() - .put(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, - String.valueOf(System.currentTimeMillis())); + CloudEvent event = CloudEventBuilder.from(handleMsgContext.getEvent()) + .withExtension(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, + String.valueOf(System.currentTimeMillis())) + .build(); + handleMsgContext.setEvent(event); String content = ""; try { - content = - new String(handleMsgContext.getMsg().getBody(), EventMeshConstants.DEFAULT_CHARSET); + String protocolType = Objects.requireNonNull(event.getExtension(Constants.PROTOCOL_TYPE)).toString(); + + ProtocolAdaptor protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + + ProtocolTransportObject protocolTransportObject = + protocolAdaptor.fromCloudEvent(handleMsgContext.getEvent()); + content = ((HttpCommand) protocolTransportObject).getBody().toMap().get("content").toString(); } catch (Exception ex) { return; } @@ -122,14 +132,14 @@ public void tryHTTPRequest() { body.add(new BasicNameValuePair(PushMessageRequestBody.CONTENT, content)); if (StringUtils.isBlank(handleMsgContext.getBizSeqNo())) { body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, - RandomStringUtil.generateNum(20))); + RandomStringUtils.generateNum(20))); } else { body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, handleMsgContext.getBizSeqNo())); } if (StringUtils.isBlank(handleMsgContext.getUniqueId())) { body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, - RandomStringUtil.generateNum(20))); + RandomStringUtils.generateNum(20))); } else { body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, handleMsgContext.getUniqueId())); @@ -140,13 +150,9 @@ public void tryHTTPRequest() { body.add(new BasicNameValuePair(PushMessageRequestBody.TOPIC, handleMsgContext.getTopic())); body.add(new BasicNameValuePair(PushMessageRequestBody.EXTFIELDS, - JsonUtils.serialize(OMSUtil.getMessageProp(handleMsgContext.getMsg())))); + JsonUtils.serialize(EventMeshUtil.getEventProp(handleMsgContext.getEvent())))); - try { - builder.setEntity(new UrlEncodedFormEntity(body)); - } catch (UnsupportedEncodingException e) { - return; - } + builder.setEntity(new UrlEncodedFormEntity(body, StandardCharsets.UTF_8)); eventMeshHTTPServer.metrics.summaryMetrics.recordPushMsg(); @@ -155,7 +161,7 @@ public void tryHTTPRequest() { addToWaitingMap(this); cmdLogger.info("cmd={}|eventMesh2client|from={}|to={}", requestCode, - IPUtil.getLocalAddress(), currPushUrl); + IPUtils.getLocalAddress(), currPushUrl); try { httpClientPool.getClient().execute(builder, new ResponseHandler() { @@ -217,9 +223,9 @@ public Object handleResponse(HttpResponse response) { }); if (messageLogger.isDebugEnabled()) { - messageLogger.debug("message|eventMesh2client|url={}|topic={}|msg={}", currPushUrl, + messageLogger.debug("message|eventMesh2client|url={}|topic={}|event={}", currPushUrl, handleMsgContext.getTopic(), - handleMsgContext.getMsg()); + handleMsgContext.getEvent()); } else { messageLogger .info("message|eventMesh2client|url={}|topic={}|bizSeqNo={}|uniqueId={}", @@ -291,13 +297,11 @@ private void addToWaitingMap(AsyncHTTPPushRequest request) { waitingRequests .put(request.handleMsgContext.getConsumerGroup(), Sets.newConcurrentHashSet()); waitingRequests.get(request.handleMsgContext.getConsumerGroup()).add(request); - return; } private void removeWaitingMap(AsyncHTTPPushRequest request) { if (waitingRequests.containsKey(request.handleMsgContext.getConsumerGroup())) { waitingRequests.get(request.handleMsgContext.getConsumerGroup()).remove(request); - return; } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcp2Client.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcp2Client.java index 17868c6e97..8c71b587d2 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcp2Client.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcp2Client.java @@ -20,13 +20,6 @@ import static org.apache.eventmesh.common.protocol.tcp.Command.REDIRECT_TO_CLIENT; import static org.apache.eventmesh.common.protocol.tcp.Command.SERVER_GOODBYE_REQUEST; -import java.net.InetSocketAddress; -import java.util.concurrent.TimeUnit; - -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelHandlerContext; - import org.apache.eventmesh.common.protocol.tcp.Header; import org.apache.eventmesh.common.protocol.tcp.OPStatus; import org.apache.eventmesh.common.protocol.tcp.Package; @@ -38,19 +31,29 @@ import org.apache.eventmesh.runtime.metrics.tcp.EventMeshTcpMonitor; import org.apache.eventmesh.runtime.util.RemotingHelper; import org.apache.eventmesh.runtime.util.Utils; + +import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; + public class EventMeshTcp2Client { private static final Logger logger = LoggerFactory.getLogger(EventMeshTcp2Client.class); - public static InetSocketAddress serverGoodby2Client(EventMeshTCPServer eventMeshTCPServer,Session session, ClientSessionGroupMapping mapping) { + public static InetSocketAddress serverGoodby2Client(EventMeshTCPServer eventMeshTCPServer, Session session, + ClientSessionGroupMapping mapping) { logger.info("serverGoodby2Client client[{}]", session.getClient()); try { long startTime = System.currentTimeMillis(); Package msg = new Package(); - msg.setHeader(new Header(SERVER_GOODBYE_REQUEST, OPStatus.SUCCESS.getCode(), "graceful normal quit from eventmesh", + msg.setHeader( + new Header(SERVER_GOODBYE_REQUEST, OPStatus.SUCCESS.getCode(), "graceful normal quit from eventmesh", null)); eventMeshTCPServer.getScheduler().submit(new Runnable() { @@ -62,7 +65,7 @@ public void run() { }); InetSocketAddress address = (InetSocketAddress) session.getContext().channel().remoteAddress(); - closeSessionIfTimeout(eventMeshTCPServer,session, mapping); + closeSessionIfTimeout(eventMeshTCPServer, session, mapping); return address; } catch (Exception e) { logger.error("exception occur while serverGoodby2Client", e); @@ -87,7 +90,7 @@ public void run() { } }, 1 * 1000, TimeUnit.MILLISECONDS); - closeSessionIfTimeout(eventMeshTCPServer,session, mapping); + closeSessionIfTimeout(eventMeshTCPServer, session, mapping); return session.getRemoteAddress(); } catch (Exception e) { @@ -101,33 +104,33 @@ public static void goodBye2Client(ChannelHandlerContext ctx, ClientSessionGroupMapping mapping, EventMeshTcpMonitor eventMeshTcpMonitor) { long startTime = System.currentTimeMillis(); - Package pkg = new Package(new Header(SERVER_GOODBYE_REQUEST, OPStatus.FAIL.getCode(), - errMsg, null)); + Package pkg = new Package(new Header(SERVER_GOODBYE_REQUEST, OPStatus.FAIL.getCode(), errMsg, null)); eventMeshTcpMonitor.getEventMesh2clientMsgNum().incrementAndGet(); logger.info("goodBye2Client client[{}]", RemotingHelper.parseChannelRemoteAddr(ctx.channel())); ctx.writeAndFlush(pkg).addListener( - new ChannelFutureListener() { - @Override - public void operationComplete(ChannelFuture future) throws Exception { - Utils.logSucceedMessageFlow(pkg, null, startTime, startTime); - try { - mapping.closeSession(ctx); - } catch (Exception e) { - logger.warn("close session failed!", e); - } + new ChannelFutureListener() { + @Override + public void operationComplete(ChannelFuture future) throws Exception { + Utils.logSucceedMessageFlow(pkg, null, startTime, startTime); + try { + mapping.closeSession(ctx); + } catch (Exception e) { + logger.warn("close session failed!", e); } } + } ); } - public static String redirectClient2NewEventMesh(EventMeshTCPServer eventMeshTCPServer,String newEventMeshIp, int port, Session session, ClientSessionGroupMapping mapping) { - logger.info("begin to gracefully redirect Client {}, newIPPort[{}]", session.getClient(), newEventMeshIp + ":" + port); + public static String redirectClient2NewEventMesh(EventMeshTCPServer eventMeshTCPServer, String newEventMeshIp, + int port, Session session, ClientSessionGroupMapping mapping) { + logger.info("begin to gracefully redirect Client {}, newIPPort[{}]", session.getClient(), + newEventMeshIp + ":" + port); try { long startTime = System.currentTimeMillis(); Package pkg = new Package(); - pkg.setHeader(new Header(REDIRECT_TO_CLIENT, OPStatus.SUCCESS.getCode(), null, - null)); + pkg.setHeader(new Header(REDIRECT_TO_CLIENT, OPStatus.SUCCESS.getCode(), null, null)); pkg.setBody(new RedirectInfo(newEventMeshIp, port)); eventMeshTCPServer.getScheduler().schedule(new Runnable() { @Override @@ -136,7 +139,7 @@ public void run() { Utils.writeAndFlush(pkg, startTime, taskExecuteTime, session.getContext(), session); } }, 5 * 1000, TimeUnit.MILLISECONDS); - closeSessionIfTimeout(eventMeshTCPServer,session, mapping); + closeSessionIfTimeout(eventMeshTCPServer, session, mapping); return session.getRemoteAddress() + "--->" + newEventMeshIp + ":" + port; } catch (Exception e) { logger.error("exception occur while redirectClient2NewEventMesh", e); @@ -144,7 +147,8 @@ public void run() { } } - public static void closeSessionIfTimeout(EventMeshTCPServer eventMeshTCPServer,Session session, ClientSessionGroupMapping mapping) { + public static void closeSessionIfTimeout(EventMeshTCPServer eventMeshTCPServer, Session session, + ClientSessionGroupMapping mapping) { eventMeshTCPServer.getScheduler().schedule(new Runnable() { @Override public void run() { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpMessageDispatcher.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpMessageDispatcher.java index df0939493f..83497bc077 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpMessageDispatcher.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpMessageDispatcher.java @@ -47,7 +47,7 @@ protected void channelRead0(ChannelHandlerContext ctx, Package pkg) throws Excep Command cmd = null; try { Runnable task; - cmd = pkg.getHeader().getCommand(); + cmd = pkg.getHeader().getCmd(); if (cmd.equals(Command.RECOMMEND_REQUEST)) { messageLogger.info("pkg|c2eventMesh|cmd={}|pkg={}", cmd, pkg); task = new RecommendTask(pkg, ctx, startTime, eventMeshTCPServer); @@ -134,7 +134,7 @@ private void validateMsg(Package pkg) throws Exception { logger.error("the incoming message does not have a header|pkg={}", pkg); throw new Exception("the incoming message does not have a header."); } - if (pkg.getHeader().getCommand() == null) { + if (pkg.getHeader().getCmd() == null) { logger.error("the incoming message does not have a command type|pkg={}", pkg); throw new Exception("the incoming message does not have a command type."); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/ClientGroupWrapper.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/ClientGroupWrapper.java index 02c2388048..e789374675 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/ClientGroupWrapper.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/ClientGroupWrapper.java @@ -17,9 +17,11 @@ package org.apache.eventmesh.runtime.core.protocol.tcp.client.group; -import org.apache.eventmesh.api.EventMeshAction; -import org.apache.eventmesh.api.EventMeshAsyncConsumeContext; -import org.apache.eventmesh.api.RRCallback; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import org.apache.eventmesh.api.*; +import org.apache.eventmesh.api.EventListener; +import org.apache.eventmesh.api.exception.OnExceptionContext; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.SubscriptionItem; import org.apache.eventmesh.common.protocol.SubscriptionMode; @@ -41,12 +43,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.Set; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReadWriteLock; @@ -55,12 +52,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import io.openmessaging.api.AsyncConsumeContext; -import io.openmessaging.api.AsyncMessageListener; -import io.openmessaging.api.Message; -import io.openmessaging.api.OnExceptionContext; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; public class ClientGroupWrapper { @@ -147,17 +138,17 @@ public boolean hasSubscription(String topic) { public boolean send(UpStreamMsgContext upStreamMsgContext, SendCallback sendCallback) throws Exception { - mqProducerWrapper.send(upStreamMsgContext.getMsg(), sendCallback); + mqProducerWrapper.send(upStreamMsgContext.getEvent(), sendCallback); return true; } - public void request(UpStreamMsgContext upStreamMsgContext, RRCallback rrCallback, long timeout) + public void request(UpStreamMsgContext upStreamMsgContext, RequestReplyCallback rrCallback, long timeout) throws Exception { - mqProducerWrapper.request(upStreamMsgContext.getMsg(), rrCallback, timeout); + mqProducerWrapper.request(upStreamMsgContext.getEvent(), rrCallback, timeout); } public boolean reply(UpStreamMsgContext upStreamMsgContext) throws Exception { - mqProducerWrapper.reply(upStreamMsgContext.getMsg(), new SendCallback() { + mqProducerWrapper.reply(upStreamMsgContext.getEvent(), new SendCallback() { @Override public void onSuccess(SendResult sendResult) { @@ -165,11 +156,9 @@ public void onSuccess(SendResult sendResult) { @Override public void onException(OnExceptionContext context) { - String bizSeqNo = upStreamMsgContext.getMsg() - .getSystemProperties(EventMeshConstants.PROPERTY_MESSAGE_KEYS); + String bizSeqNo = (String) upStreamMsgContext.getEvent().getExtension(EventMeshConstants.PROPERTY_MESSAGE_KEYS); logger.error("reply err! topic:{}, bizSeqNo:{}, client:{}", - upStreamMsgContext.getMsg() - .getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION), bizSeqNo, + upStreamMsgContext.getEvent().getSubject(), bizSeqNo, upStreamMsgContext.getSession().getClient(), context.getException()); } }); @@ -449,19 +438,24 @@ public synchronized void startClientGroupBroadcastConsumer() throws Exception { } public void subscribe(SubscriptionItem subscriptionItem) throws Exception { - AsyncMessageListener listener = null; + EventListener listener = null; if (SubscriptionMode.BROADCASTING.equals(subscriptionItem.getMode())) { - listener = new AsyncMessageListener() { + listener = new EventListener() { @Override - public void consume(Message message, AsyncConsumeContext context) { + public void consume(CloudEvent event, AsyncConsumeContext context) { eventMeshTcpMonitor.getMq2EventMeshMsgNum().incrementAndGet(); - String topic = - message.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION); - message.getSystemProperties().put(EventMeshConstants.REQ_MQ2EVENTMESH_TIMESTAMP, - String.valueOf(System.currentTimeMillis())); - message.getSystemProperties().put(EventMeshConstants.REQ_RECEIVE_EVENTMESH_IP, - eventMeshTCPConfiguration.eventMeshServerIp); + event = CloudEventBuilder.from(event) + .withExtension(EventMeshConstants.REQ_MQ2EVENTMESH_TIMESTAMP, + String.valueOf(System.currentTimeMillis())) + .withExtension(EventMeshConstants.REQ_RECEIVE_EVENTMESH_IP, + eventMeshTCPConfiguration.eventMeshServerIp).build(); + String topic = event.getSubject(); +// message.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION); +// message.getSystemProperties().put(EventMeshConstants.REQ_MQ2EVENTMESH_TIMESTAMP, +// String.valueOf(System.currentTimeMillis())); +// message.getSystemProperties().put(EventMeshConstants.REQ_RECEIVE_EVENTMESH_IP, +// eventMeshTCPConfiguration.eventMeshServerIp); EventMeshAsyncConsumeContext eventMeshAsyncConsumeContext = (EventMeshAsyncConsumeContext) context; @@ -474,7 +468,7 @@ public void consume(Message message, AsyncConsumeContext context) { Iterator sessionsItr = groupConsumerSessions.iterator(); DownStreamMsgContext downStreamMsgContext = - new DownStreamMsgContext(message, null, broadCastMsgConsumer, + new DownStreamMsgContext(event, null, broadCastMsgConsumer, eventMeshAsyncConsumeContext.getAbstractContext(), false, subscriptionItem); @@ -508,35 +502,33 @@ public void run() { }; broadCastMsgConsumer.subscribe(subscriptionItem.getTopic(), listener); } else { - listener = new AsyncMessageListener() { + listener = new EventListener() { @Override - public void consume(Message message, AsyncConsumeContext context) { + public void consume(CloudEvent event, AsyncConsumeContext context) { eventMeshTcpMonitor.getMq2EventMeshMsgNum().incrementAndGet(); - String topic = - message.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION); - message.getSystemProperties().put(EventMeshConstants.REQ_MQ2EVENTMESH_TIMESTAMP, - String.valueOf(System.currentTimeMillis())); - message.getSystemProperties().put(EventMeshConstants.REQ_RECEIVE_EVENTMESH_IP, - eventMeshTCPConfiguration.eventMeshServerIp); + event = CloudEventBuilder.from(event) + .withExtension(EventMeshConstants.REQ_MQ2EVENTMESH_TIMESTAMP, + String.valueOf(System.currentTimeMillis())) + .withExtension(EventMeshConstants.REQ_RECEIVE_EVENTMESH_IP, + eventMeshTCPConfiguration.eventMeshServerIp).build(); + String topic = event.getSubject(); EventMeshAsyncConsumeContext eventMeshAsyncConsumeContext = (EventMeshAsyncConsumeContext) context; Session session = downstreamDispatchStrategy .select(consumerGroup, topic, groupConsumerSessions); - String bizSeqNo = EventMeshUtil.getMessageBizSeq(message); + String bizSeqNo = EventMeshUtil.getMessageBizSeq(event); if (session == null) { try { Integer sendBackTimes = new Integer(0); String sendBackFromEventMeshIp = ""; - if (StringUtils.isNotBlank(message.getSystemProperties( - EventMeshConstants.EVENTMESH_SEND_BACK_TIMES))) { - sendBackTimes = Integer.valueOf(message.getSystemProperties( - EventMeshConstants.EVENTMESH_SEND_BACK_TIMES)); + if (StringUtils.isNotBlank(Objects.requireNonNull(event.getExtension( + EventMeshConstants.EVENTMESH_SEND_BACK_TIMES)).toString())) { + sendBackTimes = (Integer) event.getExtension(EventMeshConstants.EVENTMESH_SEND_BACK_TIMES); } - if (StringUtils.isNotBlank(message - .getSystemProperties(EventMeshConstants.EVENTMESH_SEND_BACK_IP))) { - sendBackFromEventMeshIp = message - .getSystemProperties(EventMeshConstants.EVENTMESH_SEND_BACK_IP); + if (StringUtils.isNotBlank(Objects.requireNonNull(event.getExtension( + EventMeshConstants.EVENTMESH_SEND_BACK_IP)).toString())) { + sendBackFromEventMeshIp = (String) event.getExtension(EventMeshConstants.EVENTMESH_SEND_BACK_IP); } logger.error( @@ -555,13 +547,12 @@ public void consume(Message message, AsyncConsumeContext context) { consumerGroup, topic, bizSeqNo); } else { sendBackTimes++; - message.getSystemProperties() - .put(EventMeshConstants.EVENTMESH_SEND_BACK_TIMES, - sendBackTimes.toString()); - message.getSystemProperties() - .put(EventMeshConstants.EVENTMESH_SEND_BACK_IP, - eventMeshTCPConfiguration.eventMeshServerIp); - sendMsgBackToBroker(message, bizSeqNo); + event = CloudEventBuilder.from(event) + .withExtension(EventMeshConstants.EVENTMESH_SEND_BACK_TIMES, + sendBackTimes.toString()) + .withExtension(EventMeshConstants.EVENTMESH_SEND_BACK_IP, + eventMeshTCPConfiguration.eventMeshServerIp).build(); + sendMsgBackToBroker(event, bizSeqNo); } } catch (Exception e) { logger.warn("handle msg exception when no session found", e); @@ -572,7 +563,7 @@ public void consume(Message message, AsyncConsumeContext context) { } DownStreamMsgContext downStreamMsgContext = - new DownStreamMsgContext(message, session, persistentMsgConsumer, + new DownStreamMsgContext(event, session, persistentMsgConsumer, eventMeshAsyncConsumeContext.getAbstractContext(), false, subscriptionItem); //msg put in eventmesh,waiting client ack @@ -659,7 +650,7 @@ public String getSysId() { return sysId; } - private String pushMsgToEventMesh(Message msg, String ip, int port) throws Exception { + private String pushMsgToEventMesh(CloudEvent msg, String ip, int port) throws Exception { StringBuilder targetUrl = new StringBuilder(); targetUrl.append("http://").append(ip).append(":").append(port) .append("/eventMesh/msg/push"); @@ -667,7 +658,7 @@ private String pushMsgToEventMesh(Message msg, String ip, int port) throws Excep try { logger.info("pushMsgToEventMesh,targetUrl:{},msg:{}", targetUrl.toString(), - msg.toString()); + msg); List paramValues = new ArrayList(); paramValues.add("msg"); paramValues.add(JsonUtils.serialize(msg)); @@ -699,14 +690,14 @@ public MQConsumerWrapper getPersistentMsgConsumer() { return persistentMsgConsumer; } - private void sendMsgBackToBroker(Message msg, String bizSeqNo) throws Exception { + private void sendMsgBackToBroker(CloudEvent event, String bizSeqNo) throws Exception { try { - String topic = msg.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION); + String topic = event.getSubject(); logger.warn("send msg back to broker, bizSeqno:{}, topic:{}", bizSeqNo, topic); long startTime = System.currentTimeMillis(); long taskExcuteTime = startTime; - send(new UpStreamMsgContext(null, msg, null, startTime, taskExcuteTime), + send(new UpStreamMsgContext(null, event, null, startTime, taskExcuteTime), new SendCallback() { @Override public void onSuccess(SendResult sendResult) { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/ClientSessionGroupMapping.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/ClientSessionGroupMapping.java index 11aa1d8c80..ce73948e27 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/ClientSessionGroupMapping.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/ClientSessionGroupMapping.java @@ -17,25 +17,10 @@ package org.apache.eventmesh.runtime.core.protocol.tcp.client.group; -import java.lang.ref.WeakReference; -import java.net.InetSocketAddress; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; - -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelHandlerContext; - -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.ThreadUtil; import org.apache.eventmesh.common.protocol.SubscriptionItem; import org.apache.eventmesh.common.protocol.SubscriptionMode; import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.common.utils.ThreadUtils; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcp2Client; @@ -46,9 +31,25 @@ import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.push.DownStreamMsgContext; import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.apache.eventmesh.runtime.util.RemotingHelper; + +import org.apache.commons.collections4.MapUtils; + +import java.lang.ref.WeakReference; +import java.net.InetSocketAddress; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; + public class ClientSessionGroupMapping { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -56,9 +57,11 @@ public class ClientSessionGroupMapping { private ConcurrentHashMap sessionTable = new ConcurrentHashMap<>(); - private ConcurrentHashMap clientGroupMap = new ConcurrentHashMap(); + private ConcurrentHashMap clientGroupMap = + new ConcurrentHashMap(); - private ConcurrentHashMap lockMap = new ConcurrentHashMap(); + private ConcurrentHashMap lockMap = + new ConcurrentHashMap(); private EventMeshTCPServer eventMeshTCPServer; @@ -123,7 +126,7 @@ public synchronized void closeSession(ChannelHandlerContext ctx) throws Exceptio @Override public void operationComplete(ChannelFuture future) throws Exception { logger.info("close the connection to remote address[{}] result: {}", remoteAddress, - future.isSuccess()); + future.isSuccess()); } }); sessionLogger.info("session|close|succeed|address={}|msg={}", addr, "no session was found"); @@ -169,7 +172,7 @@ private void closeSession(Session session) throws Exception { @Override public void operationComplete(ChannelFuture future) throws Exception { logger.info("close the connection to remote address[{}] result: {}", remoteAddress, - future.isSuccess()); + future.isSuccess()); } }); } @@ -179,7 +182,8 @@ public void operationComplete(ChannelFuture future) throws Exception { private ClientGroupWrapper constructClientGroupWrapper(String sysId, String producerGroup, String consumerGroup, EventMeshTCPServer eventMeshTCPServer, DownstreamDispatchStrategy downstreamDispatchStrategy) { - return new ClientGroupWrapper(sysId, producerGroup, consumerGroup, eventMeshTCPServer, downstreamDispatchStrategy); + return new ClientGroupWrapper(sysId, producerGroup, consumerGroup, eventMeshTCPServer, + downstreamDispatchStrategy); } private void initClientGroupWrapper(UserAgent user, Session session) throws Exception { @@ -192,7 +196,7 @@ private void initClientGroupWrapper(UserAgent user, Session session) throws Exce synchronized (lockMap.get(user.getSubsystem())) { if (!clientGroupMap.containsKey(user.getSubsystem())) { ClientGroupWrapper cgw = constructClientGroupWrapper(user.getSubsystem(), user.getProducerGroup(), - user.getConsumerGroup(), eventMeshTCPServer, new FreePriorityDispatchStrategy()); + user.getConsumerGroup(), eventMeshTCPServer, new FreePriorityDispatchStrategy()); clientGroupMap.put(user.getSubsystem(), cgw); logger.info("create new ClientGroupWrapper, subsystem:{}", user.getSubsystem()); } @@ -297,33 +301,40 @@ private void handleUnackMsgsInSession(Session session) { for (Map.Entry entry : unAckMsg.entrySet()) { DownStreamMsgContext downStreamMsgContext = entry.getValue(); if (SubscriptionMode.BROADCASTING.equals(downStreamMsgContext.subscriptionItem.getMode())) { - logger.warn("exist broadcast msg unack when closeSession,seq:{},bizSeq:{},client:{}", downStreamMsgContext.seq, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt), session.getClient()); + logger.warn("exist broadcast msg unack when closeSession,seq:{},bizSeq:{},client:{}", + downStreamMsgContext.seq, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.event), + session.getClient()); continue; } - Session reChooseSession = session.getClientGroupWrapper().get().getDownstreamDispatchStrategy().select(session.getClientGroupWrapper().get().getConsumerGroup() - , downStreamMsgContext.msgExt.getTopic() - , session.getClientGroupWrapper().get().groupConsumerSessions); - if(reChooseSession != null){ + Session reChooseSession = session.getClientGroupWrapper().get().getDownstreamDispatchStrategy() + .select(session.getClientGroupWrapper().get().getConsumerGroup(), + downStreamMsgContext.event.getSubject(), + Objects.requireNonNull(session.getClientGroupWrapper().get()).groupConsumerSessions); + if (reChooseSession != null) { downStreamMsgContext.session = reChooseSession; reChooseSession.getPusher().unAckMsg(downStreamMsgContext.seq, downStreamMsgContext); reChooseSession.downstreamMsg(downStreamMsgContext); - logger.info("rePush msg form unAckMsgs,seq:{},rePushClient:{}", entry.getKey(), downStreamMsgContext.session.getClient()); - }else{ - logger.warn("select session fail in handleUnackMsgsInSession,seq:{},topic:{}", entry.getKey(), downStreamMsgContext.msgExt.getTopic()); + logger.info("rePush msg form unAckMsgs,seq:{},rePushClient:{}", entry.getKey(), + downStreamMsgContext.session.getClient()); + } else { + logger.warn("select session fail in handleUnackMsgsInSession,seq:{},topic:{}", entry.getKey(), + downStreamMsgContext.event.getSubject()); } } } } private void cleanClientGroupWrapperCommon(Session session) throws Exception { - logger.info("GroupConsumerSessions size:{}", session.getClientGroupWrapper().get().getGroupConsumerSessions().size()); + logger.info("GroupConsumerSessions size:{}", + session.getClientGroupWrapper().get().getGroupConsumerSessions().size()); if (session.getClientGroupWrapper().get().getGroupConsumerSessions().size() == 0) { shutdownClientGroupConsumer(session); } - logger.info("GroupProducerSessions size:{}", session.getClientGroupWrapper().get().getGroupProducerSessions().size()); + logger.info("GroupProducerSessions size:{}", + session.getClientGroupWrapper().get().getGroupProducerSessions().size()); if ((session.getClientGroupWrapper().get().getGroupConsumerSessions().size() == 0) - && (session.getClientGroupWrapper().get().getGroupProducerSessions().size() == 0)) { + && (session.getClientGroupWrapper().get().getGroupProducerSessions().size() == 0)) { shutdownClientGroupProducer(session); clientGroupMap.remove(session.getClientGroupWrapper().get().getSysId()); @@ -351,22 +362,24 @@ private void shutdownClientGroupProducer(Session session) throws Exception { private void initSessionCleaner() { eventMeshTCPServer.getScheduler().scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - Iterator sessionIterator = sessionTable.values().iterator(); - while (sessionIterator.hasNext()) { - Session tmp = sessionIterator.next(); - if (System.currentTimeMillis() - tmp.getLastHeartbeatTime() > eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpSessionExpiredInMills) { - try { - logger.warn("clean expired session,client:{}", tmp.getClient()); - closeSession(tmp.getContext()); - } catch (Exception e) { - logger.error("say goodbye to session error! {}", tmp, e); - } - } - } - } - }, 1000, eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpSessionExpiredInMills, TimeUnit.MILLISECONDS); + @Override + public void run() { + Iterator sessionIterator = sessionTable.values().iterator(); + while (sessionIterator.hasNext()) { + Session tmp = sessionIterator.next(); + if (System.currentTimeMillis() - tmp.getLastHeartbeatTime() + > eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpSessionExpiredInMills) { + try { + logger.warn("clean expired session,client:{}", tmp.getClient()); + closeSession(tmp.getContext()); + } catch (Exception e) { + logger.error("say goodbye to session error! {}", tmp, e); + } + } + } + } + }, 1000, eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpSessionExpiredInMills, + TimeUnit.MILLISECONDS); } private void initDownStreamMsgContextCleaner() { @@ -387,7 +400,7 @@ public void run() { downStreamMsgContext.ackMsg(); tmp.getPusher().getUnAckMsg().remove(seqKey); logger.warn("remove expire downStreamMsgContext, session:{}, topic:{}, seq:{}", tmp, - downStreamMsgContext.msgExt.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION), seqKey); + downStreamMsgContext.event.getSubject(), seqKey); } } } @@ -407,8 +420,8 @@ public void start() throws Exception { public void shutdown() throws Exception { logger.info("begin to close sessions gracefully"); - for(ClientGroupWrapper clientGroupWrapper : clientGroupMap.values()){ - for(Session subSession : clientGroupWrapper.getGroupConsumerSessions()){ + for (ClientGroupWrapper clientGroupWrapper : clientGroupMap.values()) { + for (Session subSession : clientGroupWrapper.getGroupConsumerSessions()) { try { EventMeshTcp2Client.serverGoodby2Client(eventMeshTCPServer, subSession, this); } catch (Exception e) { @@ -416,7 +429,7 @@ public void shutdown() throws Exception { } } - for(Session pubSession : clientGroupWrapper.getGroupProducerSessions()){ + for (Session pubSession : clientGroupWrapper.getGroupProducerSessions()) { try { EventMeshTcp2Client.serverGoodby2Client(eventMeshTCPServer, pubSession, this); } catch (Exception e) { @@ -438,12 +451,12 @@ public void shutdown() throws Exception { sessionTable.values().parallelStream().forEach(itr -> { try { - EventMeshTcp2Client.serverGoodby2Client(this.eventMeshTCPServer,itr, this); + EventMeshTcp2Client.serverGoodby2Client(this.eventMeshTCPServer, itr, this); } catch (Exception e) { logger.error("say goodbye to session error! {}", itr, e); } }); - ThreadUtil.randomSleep(50); + ThreadUtils.randomSleep(50); logger.info("ClientSessionGroupMapping shutdown......"); } @@ -471,15 +484,15 @@ public Map> prepareEventMeshClientDistributionData( return result; } - public Map> prepareProxyClientDistributionData(){ + public Map> prepareProxyClientDistributionData() { Map> result = null; - if(!clientGroupMap.isEmpty()){ + if (!clientGroupMap.isEmpty()) { result = new HashMap<>(); - for(Map.Entry entry : clientGroupMap.entrySet()){ - Map map = new HashMap(); - map.put(EventMeshConstants.PURPOSE_SUB,entry.getValue().getGroupConsumerSessions().size()); - map.put(EventMeshConstants.PURPOSE_PUB,entry.getValue().getGroupProducerSessions().size()); + for (Map.Entry entry : clientGroupMap.entrySet()) { + Map map = new HashMap<>(); + map.put(EventMeshConstants.PURPOSE_SUB, entry.getValue().getGroupConsumerSessions().size()); + map.put(EventMeshConstants.PURPOSE_PUB, entry.getValue().getGroupProducerSessions().size()); result.put(entry.getKey(), map); } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/rebalance/EventmeshRebalanceImpl.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/rebalance/EventmeshRebalanceImpl.java index 204f9ed411..2929705542 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/rebalance/EventmeshRebalanceImpl.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/rebalance/EventmeshRebalanceImpl.java @@ -97,59 +97,108 @@ private Map queryLocalEventMeshMap(String cluster){ } private void doRebalanceByGroup(String cluster, String group, String purpose, Map eventMeshMap) throws Exception{ + logger.info("doRebalanceByGroup start, cluster:{}, group:{}, purpose:{}", cluster, group, purpose); + //query distribute data of loacl idc Map clientDistributionMap = queryLocalEventMeshDistributeData(cluster, group, purpose, eventMeshMap); if(clientDistributionMap == null || clientDistributionMap.size() == 0){ return; } + doRebalanceRedirect(eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshName, group, purpose, eventMeshMap, clientDistributionMap); + logger.info("doRebalanceByGroup end, cluster:{}, group:{}, purpose:{}", cluster, group, purpose); + + } + + private void doRebalanceRedirect(String currEventMeshName, String group, String purpose, Map eventMeshMap, Map clientDistributionMap)throws Exception{ + if(clientDistributionMap == null || clientDistributionMap.size() == 0){ + return; + } + + //caculate client num need to redirect in currEventMesh + int judge = caculateRedirectNum(currEventMeshName, group, purpose, clientDistributionMap); + + if(judge > 0) { + + //select redirect target eventmesh lisg + List eventMeshRecommendResult = selectRedirectEventMesh(group, eventMeshMap, clientDistributionMap, judge, currEventMeshName); + if(eventMeshRecommendResult == null || eventMeshRecommendResult.size() != judge){ + logger.warn("doRebalance failed,recommendEventMeshNum is not consistent,recommendResult:{},judge:{}", eventMeshRecommendResult, judge); + return; + } + + //do redirect + doRedirect(group, purpose, judge, eventMeshRecommendResult); + }else{ + logger.info("rebalance condition not satisfy,group:{}, purpose:{},judge:{}", group, purpose, judge); + } + } + + private void doRedirect(String group, String purpose, int judge, List eventMeshRecommendResult) throws Exception{ + logger.info("doRebalance redirect start---------------------group:{},judge:{}", group, judge); + Set sessionSet = null; + if(EventMeshConstants.PURPOSE_SUB.equals(purpose)) { + sessionSet = eventMeshTCPServer.getClientSessionGroupMapping().getClientGroupMap().get(group).getGroupConsumerSessions(); + }else if(EventMeshConstants.PURPOSE_PUB.equals(purpose)){ + sessionSet = eventMeshTCPServer.getClientSessionGroupMapping().getClientGroupMap().get(group).getGroupProducerSessions(); + }else{ + logger.warn("doRebalance failed,param is illegal, group:{}, purpose:{}",group, purpose); + return; + } + List sessionList = new ArrayList<>(sessionSet); + Collections.shuffle(new ArrayList<>(sessionList)); + + for(int i= 0; i selectRedirectEventMesh(String group, Map eventMeshMap, Map clientDistributionMap, int judge, String evenMeshName)throws Exception{ + EventMeshRecommendStrategy eventMeshRecommendStrategy = new EventMeshRecommendImpl(eventMeshTCPServer); + return eventMeshRecommendStrategy.calculateRedirectRecommendEventMesh(eventMeshMap, clientDistributionMap, group, judge, evenMeshName); + } + + public int caculateRedirectNum(String eventMeshName, String group, String purpose, Map clientDistributionMap) throws Exception{ int sum = 0; for(Integer item : clientDistributionMap.values()){ sum += item.intValue(); } int currentNum = 0; - if(clientDistributionMap.get(eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshName) != null){ - currentNum = clientDistributionMap.get(eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshName); + if(clientDistributionMap.get(eventMeshName) != null){ + currentNum = clientDistributionMap.get(eventMeshName); } int avgNum = sum / clientDistributionMap.size(); - int judge = avgNum >= 2 ? avgNum/2 : 1; - - if(currentNum - avgNum > judge) { - Set sessionSet = null; - if(EventMeshConstants.PURPOSE_PUB.equals(purpose)){ - sessionSet = eventMeshTCPServer.getClientSessionGroupMapping().getClientGroupMap().get(group).getGroupProducerSessions(); - }else if(EventMeshConstants.PURPOSE_SUB.equals(purpose)){ - sessionSet = eventMeshTCPServer.getClientSessionGroupMapping().getClientGroupMap().get(group).getGroupConsumerSessions(); - }else{ - logger.warn("doRebalance failed,purpose is not support,purpose:{}", purpose); - return; + int modNum = sum % clientDistributionMap.size(); + + List eventMeshList = new ArrayList<>(clientDistributionMap.keySet()); + Collections.sort(eventMeshList); + int index = -1; + for(int i=0; i < Math.min(modNum, eventMeshList.size()); i++){ + if(StringUtils.equals(eventMeshName, eventMeshList.get(i))){ + index = i; + break; } - - List sessionList = new ArrayList<>(sessionSet); - Collections.shuffle(new ArrayList<>(sessionList)); - EventMeshRecommendStrategy eventMeshRecommendStrategy = new EventMeshRecommendImpl(eventMeshTCPServer); - List eventMeshRecommendResult = eventMeshRecommendStrategy.calculateRedirectRecommendEventMesh(eventMeshMap, clientDistributionMap, group, judge); - if(eventMeshRecommendResult == null || eventMeshRecommendResult.size() != judge){ - logger.warn("doRebalance failed,recommendProxyNum is not consistent,recommendResult:{},judge:{}", eventMeshRecommendResult, judge); - return; - } - logger.info("doRebalance redirect start---------------------group:{},purpose:{},judge:{}", group, purpose, judge); - for(int i= 0; i= 0) ? avgNum + 1 : avgNum; + } + logger.info("rebalance caculateRedirectNum,group:{}, purpose:{},sum:{},avgNum:{}," + + "modNum:{}, index:{}, currentNum:{}, rebalanceResult:{}", group, purpose, sum, + avgNum, modNum, index, currentNum, rebalanceResult); + return currentNum - rebalanceResult; } private Map queryLocalEventMeshDistributeData(String cluster, String group, String purpose, Map eventMeshMap){ @@ -197,12 +246,4 @@ private Map queryLocalEventMeshDistributeData(String cluster, S return localEventMeshDistributeData; } - - - private class ValueComparator implements Comparator> { - @Override - public int compare(Map.Entry x, Map.Entry y) { - return x.getValue().intValue() - y.getValue().intValue(); - } - } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/recommend/EventMeshRecommendImpl.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/recommend/EventMeshRecommendImpl.java index 6c8b4a349c..4b5091f413 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/recommend/EventMeshRecommendImpl.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/recommend/EventMeshRecommendImpl.java @@ -90,8 +90,11 @@ public String calculateRecommendEventMesh(String group, String purpose) throws E } @Override - public List calculateRedirectRecommendEventMesh(Map eventMeshMap, Map clientDistributeMap, String group, int recommendProxyNum) throws Exception { - logger.info("eventMeshMap:{},clientDistributionMap:{},group:{},recommendNum:{}", eventMeshMap,clientDistributeMap,group,recommendProxyNum); + public List calculateRedirectRecommendEventMesh(Map eventMeshMap, Map clientDistributeMap, String group, int recommendProxyNum, String eventMeshName) throws Exception { + if(recommendProxyNum < 1){ + return null; + } + logger.info("eventMeshMap:{},clientDistributionMap:{},group:{},recommendNum:{},currEventMeshName:{}", eventMeshMap,clientDistributeMap,group,recommendProxyNum, eventMeshName); List recommendProxyList = null; //find eventmesh with least client @@ -106,10 +109,10 @@ public List calculateRedirectRecommendEventMesh(Map even recommendProxyList = new ArrayList<>(recommendProxyNum); while(recommendProxyList.size() < recommendProxyNum){ Map.Entry minProxyItem = list.get(0); - int currProxyNum = clientDistributeMap.get(eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshName); + int currProxyNum = clientDistributeMap.get(eventMeshName); recommendProxyList.add(eventMeshMap.get(minProxyItem.getKey())); clientDistributeMap.put(minProxyItem.getKey(),minProxyItem.getValue() + 1); - clientDistributeMap.put(eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshName,currProxyNum - 1); + clientDistributeMap.put(eventMeshName,currProxyNum - 1); Collections.sort(list, vc); logger.info("clientDistributionMap after sort:{}", list); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/recommend/EventMeshRecommendStrategy.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/recommend/EventMeshRecommendStrategy.java index 3cc5044f1e..f17a513fe2 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/recommend/EventMeshRecommendStrategy.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/recommend/EventMeshRecommendStrategy.java @@ -22,5 +22,5 @@ public interface EventMeshRecommendStrategy { String calculateRecommendEventMesh(String group, String purpose) throws Exception; - List calculateRedirectRecommendEventMesh(Map eventMeshMap, Map clientDistributeMap, String group, int recommendNum) throws Exception; + List calculateRedirectRecommendEventMesh(Map eventMeshMap, Map clientDistributeMap, String group, int recommendNum, String eventMeshName) throws Exception; } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/Session.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/Session.java index 11c468b3c2..e241bb2ab3 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/Session.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/Session.java @@ -24,13 +24,13 @@ import java.util.List; import java.util.concurrent.locks.ReentrantLock; +import io.cloudevents.CloudEvent; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.openmessaging.api.Message; -import io.openmessaging.api.SendCallback; import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.api.SendCallback; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.SubscriptionItem; import org.apache.eventmesh.common.protocol.tcp.*; @@ -185,10 +185,10 @@ public void unsubscribe(List items) throws Exception { } } - public EventMeshTcpSendResult upstreamMsg(Header header, Message msg, SendCallback sendCallback, long startTime, long taskExecuteTime) { - String topic = msg.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION); + public EventMeshTcpSendResult upstreamMsg(Header header, CloudEvent event, SendCallback sendCallback, long startTime, long taskExecuteTime) { + String topic = event.getSubject(); sessionContext.sendTopics.putIfAbsent(topic, topic); - return sender.send(header, msg, sendCallback, startTime, taskExecuteTime); + return sender.send(header, event, sendCallback, startTime, taskExecuteTime); } public void downstreamMsg(DownStreamMsgContext downStreamMsgContext) { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/ClientAckContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/ClientAckContext.java index 015fb467a6..3b1e0dbbed 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/ClientAckContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/ClientAckContext.java @@ -19,8 +19,7 @@ import java.util.List; -import io.openmessaging.api.Message; - +import io.cloudevents.CloudEvent; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; @@ -44,17 +43,17 @@ public class ClientAckContext { private long expireTime; - private List msgs; + private List events; private MQConsumerWrapper consumer; - public ClientAckContext(String seq, AbstractContext context, List msgs, MQConsumerWrapper consumer) { + public ClientAckContext(String seq, AbstractContext context, List events, MQConsumerWrapper consumer) { this.seq = seq; this.context = context; - this.msgs = msgs; + this.events = events; this.consumer = consumer; this.createTime = System.currentTimeMillis(); - String ttlStr = msgs.get(0).getUserProperties(EventMeshConstants.PROPERTY_MESSAGE_TTL); + String ttlStr = events.get(0).getExtension(EventMeshConstants.PROPERTY_MESSAGE_TTL).toString(); long ttl = StringUtils.isNumeric(ttlStr)? Long.parseLong(ttlStr) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS; this.expireTime = System.currentTimeMillis() + ttl; } @@ -87,12 +86,12 @@ public void setCreateTime(long createTime) { this.createTime = createTime; } - public List getMsgs() { - return msgs; + public List getEvents() { + return events; } - public void setMsgs(List msgs) { - this.msgs = msgs; + public void setEvents(List events) { + this.events = events; } public long getExpireTime() { @@ -108,13 +107,13 @@ public MQConsumerWrapper getConsumer() { } public void ackMsg() { - if (consumer != null && context != null && msgs != null) { - consumer.updateOffset(msgs, context); + if (consumer != null && context != null && events != null) { + consumer.updateOffset(events, context); // ConsumeMessageService consumeMessageService = consumer..getDefaultMQPushConsumerImpl().getConsumeMessageService(); // ((ConsumeMessageConcurrentlyService)consumeMessageService).updateOffset(msgs, context); - logger.info("ackMsg topic:{}, bizSeq:{}", msgs.get(0).getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION), EventMeshUtil.getMessageBizSeq(msgs.get(0))); + logger.info("ackMsg topic:{}, bizSeq:{}", events.get(0).getSubject(), EventMeshUtil.getMessageBizSeq(events.get(0))); } else { - logger.warn("ackMsg failed,consumer is null:{}, context is null:{} , msgs is null:{}", consumer == null, context == null, msgs == null); + logger.warn("ackMsg failed,consumer is null:{}, context is null:{} , msgs is null:{}", consumer == null, context == null, events == null); } } @@ -124,7 +123,7 @@ public String toString() { ",seq=" + seq + // TODO ",consumer=" + consumer.getDefaultMQPushConsumer().getMessageModel() + // ",consumerGroup=" + consumer.getDefaultMQPushConsumer().getConsumerGroup() + - ",topic=" + (CollectionUtils.size(msgs) > 0 ? msgs.get(0).getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION) : null) + + ",topic=" + (CollectionUtils.size(events) > 0 ? events.get(0).getSubject() : null) + ",createTime=" + DateFormatUtils.format(createTime, EventMeshConstants.DATE_FORMAT) + ",expireTime=" + DateFormatUtils.format(expireTime, EventMeshConstants.DATE_FORMAT) + '}'; } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/DownStreamMsgContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/DownStreamMsgContext.java index 5b86ba3879..cb6b7d845e 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/DownStreamMsgContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/DownStreamMsgContext.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.push; -import io.openmessaging.api.Message; +import io.cloudevents.CloudEvent; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.eventmesh.api.AbstractContext; @@ -55,16 +55,17 @@ public class DownStreamMsgContext extends RetryContext { public boolean msgFromOtherEventMesh; - public DownStreamMsgContext(Message msgExt, Session session, MQConsumerWrapper consumer, AbstractContext consumeConcurrentlyContext, boolean msgFromOtherEventMesh, SubscriptionItem subscriptionItem) { + public DownStreamMsgContext(CloudEvent event, Session session, MQConsumerWrapper consumer, AbstractContext consumeConcurrentlyContext, boolean msgFromOtherEventMesh, SubscriptionItem subscriptionItem) { this.seq = String.valueOf(ServerGlobal.getInstance().getMsgCounter().incrementAndGet()); - this.msgExt = msgExt; + this.event = event; this.session = session; this.consumer = consumer; this.consumeConcurrentlyContext = consumeConcurrentlyContext; this.lastPushTime = System.currentTimeMillis(); this.createTime = System.currentTimeMillis(); this.subscriptionItem = subscriptionItem; - String ttlStr = msgExt.getUserProperties("TTL"); + String ttlStr = (String) event.getExtension("TTL"); +// String ttlStr = msgExt.getUserProperties("TTL"); long ttl = StringUtils.isNumeric(ttlStr) ? Long.parseLong(ttlStr) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS; this.expireTime = System.currentTimeMillis() + ttl; this.msgFromOtherEventMesh = msgFromOtherEventMesh; @@ -75,16 +76,16 @@ public boolean isExpire() { } public void ackMsg() { - if (consumer != null && consumeConcurrentlyContext != null && msgExt != null) { - List msgs = new ArrayList(); - msgs.add(msgExt); - consumer.updateOffset(msgs, consumeConcurrentlyContext); + if (consumer != null && consumeConcurrentlyContext != null && event != null) { + List events = new ArrayList(); + events.add(event); + consumer.updateOffset(events, consumeConcurrentlyContext); // ConsumeMessageService consumeMessageService = consumer.getDefaultMQPushConsumer().getDefaultMQPushConsumerImpl().getConsumeMessageService(); // ((ConsumeMessageConcurrentlyService)consumeMessageService).updateOffset(msgs, consumeConcurrentlyContext); - logger.info("ackMsg seq:{}, topic:{}, bizSeq:{}", seq, msgs.get(0).getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION), - msgs.get(0).getSystemProperties(EventMeshConstants.PROPERTY_MESSAGE_KEYS)); + logger.info("ackMsg seq:{}, topic:{}, bizSeq:{}", seq, events.get(0).getSubject(), + events.get(0).getExtension(EventMeshConstants.PROPERTY_MESSAGE_KEYS)); } else { - logger.warn("ackMsg seq:{} failed,consumer is null:{}, context is null:{} , msgs is null:{}", seq, consumer == null, consumeConcurrentlyContext == null, msgExt == null); + logger.warn("ackMsg seq:{} failed,consumer is null:{}, context is null:{} , msgs is null:{}", seq, consumer == null, consumeConcurrentlyContext == null, event == null); } } @@ -96,7 +97,7 @@ public String toString() { ",retryTimes=" + retryTimes + ",consumer=" + consumer + // todo ",consumerGroup=" + consumer.getClass().getConsumerGroup() + - ",topic=" + msgExt.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION) + + ",topic=" + event.getSubject() + ",subscriptionItem=" + subscriptionItem + ",createTime=" + DateFormatUtils.format(createTime, EventMeshConstants.DATE_FORMAT) + ",executeTime=" + DateFormatUtils.format(executeTime, EventMeshConstants.DATE_FORMAT) + @@ -106,7 +107,7 @@ public String toString() { @Override public void retry() { try { - logger.info("retry downStream msg start,seq:{},retryTimes:{},bizSeq:{}", this.seq, this.retryTimes, EventMeshUtil.getMessageBizSeq(this.msgExt)); + logger.info("retry downStream msg start,seq:{},retryTimes:{},bizSeq:{}", this.seq, this.retryTimes, EventMeshUtil.getMessageBizSeq(this.event)); if (isRetryMsgTimeout(this)) { return; @@ -115,22 +116,21 @@ public void retry() { this.lastPushTime = System.currentTimeMillis(); Session rechoosen = null; - String topic = this.msgExt.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION); + String topic = this.event.getSubject(); if (!SubscriptionMode.BROADCASTING.equals(this.subscriptionItem.getMode())) { rechoosen = this.session.getClientGroupWrapper() .get().getDownstreamDispatchStrategy().select(this.session.getClientGroupWrapper().get().getSysId() - , topic - , this.session.getClientGroupWrapper().get().getGroupConsumerSessions()); + , topic, this.session.getClientGroupWrapper().get().getGroupConsumerSessions()); } else { rechoosen = this.session; } if (rechoosen == null) { - logger.warn("retry, found no session to downstream msg,seq:{}, retryTimes:{}, bizSeq:{}", this.seq, this.retryTimes, EventMeshUtil.getMessageBizSeq(this.msgExt)); + logger.warn("retry, found no session to downstream msg,seq:{}, retryTimes:{}, bizSeq:{}", this.seq, this.retryTimes, EventMeshUtil.getMessageBizSeq(this.event)); } else { this.session = rechoosen; rechoosen.downstreamMsg(this); - logger.info("retry downStream msg end,seq:{},retryTimes:{},bizSeq:{}", this.seq, this.retryTimes, EventMeshUtil.getMessageBizSeq(this.msgExt)); + logger.info("retry downStream msg end,seq:{},retryTimes:{},bizSeq:{}", this.seq, this.retryTimes, EventMeshUtil.getMessageBizSeq(this.event)); } } catch (Exception e) { logger.error("retry-dispatcher error!", e); @@ -139,19 +139,19 @@ public void retry() { private boolean isRetryMsgTimeout(DownStreamMsgContext downStreamMsgContext) { boolean flag = false; - String ttlStr = downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.PROPERTY_MESSAGE_TTL); - long ttl = StringUtils.isNumeric(ttlStr)? Long.parseLong(ttlStr) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS;; + String ttlStr = (String) downStreamMsgContext.event.getExtension(EventMeshConstants.PROPERTY_MESSAGE_TTL); + long ttl = StringUtils.isNumeric(ttlStr) ? Long.parseLong(ttlStr) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS;; - String storeTimeStr = downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.STORE_TIME); - long storeTimestamp = StringUtils.isNumeric(storeTimeStr)? Long.parseLong(storeTimeStr) : 0; - String leaveTimeStr = downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.LEAVE_TIME); + String storeTimeStr = (String) downStreamMsgContext.event.getExtension(EventMeshConstants.STORE_TIME); + long storeTimestamp = StringUtils.isNumeric(storeTimeStr) ? Long.parseLong(storeTimeStr) : 0; + String leaveTimeStr = (String) downStreamMsgContext.event.getExtension(EventMeshConstants.LEAVE_TIME); long brokerCost = StringUtils.isNumeric(leaveTimeStr) ? Long.parseLong(leaveTimeStr) - storeTimestamp : 0; - String arriveTimeStr = downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.ARRIVE_TIME); + String arriveTimeStr = (String) downStreamMsgContext.event.getExtension(EventMeshConstants.ARRIVE_TIME); long accessCost = StringUtils.isNumeric(arriveTimeStr) ? System.currentTimeMillis() - Long.parseLong(arriveTimeStr) : 0; double elapseTime = brokerCost + accessCost; if (elapseTime >= ttl) { - logger.warn("discard the retry because timeout, seq:{}, retryTimes:{}, bizSeq:{}", downStreamMsgContext.seq, downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt)); + logger.warn("discard the retry because timeout, seq:{}, retryTimes:{}, bizSeq:{}", downStreamMsgContext.seq, downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.event)); flag = true; eventMeshAckMsg(downStreamMsgContext); } @@ -164,10 +164,10 @@ private boolean isRetryMsgTimeout(DownStreamMsgContext downStreamMsgContext) { * @param downStreamMsgContext */ private void eventMeshAckMsg(DownStreamMsgContext downStreamMsgContext) { - List msgExts = new ArrayList(); - msgExts.add(downStreamMsgContext.msgExt); - logger.warn("eventMeshAckMsg topic:{}, seq:{}, bizSeq:{}", downStreamMsgContext.msgExt.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION), - downStreamMsgContext.seq, downStreamMsgContext.msgExt.getSystemProperties(EventMeshConstants.PROPERTY_MESSAGE_KEYS)); + List msgExts = new ArrayList(); + msgExts.add(downStreamMsgContext.event); + logger.warn("eventMeshAckMsg topic:{}, seq:{}, bizSeq:{}", downStreamMsgContext.event.getSubject(), + downStreamMsgContext.seq, downStreamMsgContext.event.getExtension(EventMeshConstants.PROPERTY_MESSAGE_KEYS)); downStreamMsgContext.consumer.updateOffset(msgExts, downStreamMsgContext.consumeConcurrentlyContext); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/SessionPusher.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/SessionPusher.java index 4b78332938..ef339f0999 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/SessionPusher.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/SessionPusher.java @@ -17,19 +17,24 @@ package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.push; +import io.cloudevents.core.builder.CloudEventBuilder; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import org.apache.commons.collections4.CollectionUtils; +import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.SubscriptionType; import org.apache.eventmesh.common.protocol.SubscriptionMode; import org.apache.eventmesh.common.protocol.tcp.*; import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; @@ -69,16 +74,24 @@ public void push(final DownStreamMsgContext downStreamMsgContext) { cmd = Command.ASYNC_MESSAGE_TO_CLIENT; } + String protocolType = Objects.requireNonNull(downStreamMsgContext.event.getExtension(Constants.PROTOCOL_TYPE)).toString(); + + ProtocolAdaptor protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + Package pkg = new Package(); - downStreamMsgContext.msgExt.getSystemProperties().put(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, String.valueOf(System.currentTimeMillis())); + + downStreamMsgContext.event = CloudEventBuilder.from(downStreamMsgContext.event) + .withExtension(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .build(); +// downStreamMsgContext.event.getSystemProperties().put(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, String.valueOf(System.currentTimeMillis())); EventMeshMessage body = null; int retCode = 0; String retMsg = null; try { - body = EventMeshUtil.encodeMessage(downStreamMsgContext.msgExt); - pkg.setBody(body); + pkg = (Package) protocolAdaptor.fromCloudEvent(downStreamMsgContext.event); pkg.setHeader(new Header(cmd, OPStatus.SUCCESS.getCode(), null, downStreamMsgContext.seq)); - messageLogger.info("pkg|mq2eventMesh|cmd={}|mqMsg={}|user={}", cmd, EventMeshUtil.printMqMessage(body), session.getClient()); + pkg.getHeader().putProperty(Constants.PROTOCOL_TYPE, protocolType); + messageLogger.info("pkg|mq2eventMesh|cmd={}|mqMsg={}|user={}", cmd, pkg, session.getClient()); } catch (Exception e) { pkg.setHeader(new Header(cmd, OPStatus.FAIL.getCode(), e.getStackTrace().toString(), downStreamMsgContext.seq)); retCode = -1; @@ -91,7 +104,7 @@ public void push(final DownStreamMsgContext downStreamMsgContext) { @Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { - logger.error("downstreamMsg fail,seq:{}, retryTimes:{}, msg:{}", downStreamMsgContext.seq, downStreamMsgContext.retryTimes, downStreamMsgContext.msgExt); + logger.error("downstreamMsg fail,seq:{}, retryTimes:{}, event:{}", downStreamMsgContext.seq, downStreamMsgContext.retryTimes, downStreamMsgContext.event); deliverFailMsgsCount.incrementAndGet(); //how long to isolate client when push fail @@ -108,7 +121,7 @@ public void operationComplete(ChannelFuture future) throws Exception { } else { deliveredMsgsCount.incrementAndGet(); logger.info("downstreamMsg success,seq:{}, retryTimes:{}, bizSeq:{}", downStreamMsgContext.seq, - downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt)); + downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.event)); if (session.isIsolated()) { logger.info("cancel isolated,client:{}", session.getClient()); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/retry/EventMeshTcpRetryer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/retry/EventMeshTcpRetryer.java index c43ef4ffe2..ba8f96cd4b 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/retry/EventMeshTcpRetryer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/retry/EventMeshTcpRetryer.java @@ -63,27 +63,27 @@ public void pushRetry(RetryContext retryContext) { if (retrys.size() >= eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpMsgRetryQueueSize) { logger.error("pushRetry fail,retrys is too much,allow max retryQueueSize:{}, retryTimes:{}, seq:{}, bizSeq:{}", eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpMsgRetryQueueSize, retryContext.retryTimes, - retryContext.seq, EventMeshUtil.getMessageBizSeq(retryContext.msgExt)); + retryContext.seq, EventMeshUtil.getMessageBizSeq(retryContext.event)); return; } int maxRetryTimes = eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpMsgAsyncRetryTimes; if (retryContext instanceof DownStreamMsgContext) { DownStreamMsgContext downStreamMsgContext = (DownStreamMsgContext) retryContext; - maxRetryTimes = SubscriptionType.SYNC.equals(downStreamMsgContext.subscriptionItem.getType()) ? - eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpMsgSyncRetryTimes : + maxRetryTimes = SubscriptionType.SYNC.equals(downStreamMsgContext.subscriptionItem.getType()) + ? eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpMsgSyncRetryTimes : eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpMsgAsyncRetryTimes; } if (retryContext.retryTimes >= maxRetryTimes) { logger.warn("pushRetry fail,retry over maxRetryTimes:{}, retryTimes:{}, seq:{}, bizSeq:{}", maxRetryTimes, - retryContext.retryTimes, retryContext.seq, EventMeshUtil.getMessageBizSeq(retryContext.msgExt)); + retryContext.retryTimes, retryContext.seq, EventMeshUtil.getMessageBizSeq(retryContext.event)); return; } retrys.offer(retryContext); logger.info("pushRetry success,seq:{}, retryTimes:{}, bizSeq:{}", retryContext.seq, retryContext.retryTimes, - EventMeshUtil.getMessageBizSeq(retryContext.msgExt)); + EventMeshUtil.getMessageBizSeq(retryContext.event)); } public void init() { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/retry/RetryContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/retry/RetryContext.java index 04d8674d7f..373f3ed357 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/retry/RetryContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/retry/RetryContext.java @@ -17,13 +17,14 @@ package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.retry; -import io.openmessaging.api.Message; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; +import io.cloudevents.CloudEvent; + public abstract class RetryContext implements Delayed { - public Message msgExt; + public CloudEvent event; public String seq; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/SessionSender.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/SessionSender.java index e9e1fc53a7..3401088721 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/SessionSender.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/SessionSender.java @@ -17,16 +17,18 @@ package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.send; -import io.openmessaging.api.Message; -import io.openmessaging.api.SendCallback; +import io.cloudevents.core.builder.CloudEventBuilder; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; -import org.apache.eventmesh.api.RRCallback; +import org.apache.eventmesh.api.RequestReplyCallback; +import org.apache.eventmesh.api.SendCallback; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.tcp.Command; import org.apache.eventmesh.common.protocol.tcp.Header; import org.apache.eventmesh.common.protocol.tcp.OPStatus; import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; import org.apache.eventmesh.runtime.util.EventMeshUtil; @@ -34,10 +36,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Objects; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; +import io.cloudevents.CloudEvent; + public class SessionSender { private final Logger messageLogger = LoggerFactory.getLogger("message"); @@ -72,24 +77,30 @@ public SessionSender(Session session) { this.upstreamBuff = new Semaphore(session.getEventMeshTCPConfiguration().eventMeshTcpSessionUpstreamBufferSize); } - public EventMeshTcpSendResult send(Header header, Message msg, SendCallback sendCallback, long startTime, long taskExecuteTime) { + public EventMeshTcpSendResult send(Header header, CloudEvent event, SendCallback sendCallback, long startTime, long taskExecuteTime) { try { if (upstreamBuff.tryAcquire(TRY_PERMIT_TIME_OUT, TimeUnit.MILLISECONDS)) { upMsgs.incrementAndGet(); UpStreamMsgContext upStreamMsgContext = null; - Command cmd = header.getCommand(); + Command cmd = header.getCmd(); + long ttl = EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS; if (Command.REQUEST_TO_SERVER == cmd) { - long ttl = msg.getSystemProperties(EventMeshConstants.PROPERTY_MESSAGE_TTL) != null ? Long.parseLong(msg.getSystemProperties(EventMeshConstants.PROPERTY_MESSAGE_TTL)) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS; - upStreamMsgContext = new UpStreamMsgContext(session, msg, header, startTime, taskExecuteTime); + if (event.getExtension(EventMeshConstants.PROPERTY_MESSAGE_TTL) != null) { + ttl = Long.parseLong((String) Objects.requireNonNull(event.getExtension(EventMeshConstants.PROPERTY_MESSAGE_TTL))); + } +// long ttl = msg.getSystemProperties(EventMeshConstants.PROPERTY_MESSAGE_TTL) != null ? Long.parseLong(msg.getSystemProperties(EventMeshConstants.PROPERTY_MESSAGE_TTL)) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS; + upStreamMsgContext = new UpStreamMsgContext(session, event, header, startTime, taskExecuteTime); session.getClientGroupWrapper().get().request(upStreamMsgContext, initSyncRRCallback(header, startTime, taskExecuteTime), ttl); upstreamBuff.release(); } else if (Command.RESPONSE_TO_SERVER == cmd) { - String cluster = msg.getUserProperties(EventMeshConstants.PROPERTY_MESSAGE_CLUSTER); + String cluster = (String)event.getExtension(EventMeshConstants.PROPERTY_MESSAGE_CLUSTER); +// String cluster = msg.getUserProperties(EventMeshConstants.PROPERTY_MESSAGE_CLUSTER); if (!StringUtils.isEmpty(cluster)) { String replyTopic = EventMeshConstants.RR_REPLY_TOPIC; replyTopic = cluster + "-" + replyTopic; - msg.getSystemProperties().put(Constants.PROPERTY_MESSAGE_DESTINATION, replyTopic); - msg.setTopic(replyTopic); + event = CloudEventBuilder.from(event).withSubject(replyTopic).build(); +// msg.getSystemProperties().put(Constants.PROPERTY_MESSAGE_DESTINATION, replyTopic); +// event(replyTopic); } // //for rocketmq support @@ -97,11 +108,11 @@ public EventMeshTcpSendResult send(Header header, Message msg, SendCallback send // MessageAccessor.putProperty(msg, MessageConst.PROPERTY_CORRELATION_ID, msg.getProperty(DeFiBusConstant.PROPERTY_RR_REQUEST_ID)); // MessageAccessor.putProperty(msg, MessageConst.PROPERTY_MESSAGE_REPLY_TO_CLIENT, msg.getProperty(DeFiBusConstant.PROPERTY_MESSAGE_REPLY_TO)); - upStreamMsgContext = new UpStreamMsgContext(session, msg, header, startTime, taskExecuteTime); + upStreamMsgContext = new UpStreamMsgContext(session, event, header, startTime, taskExecuteTime); session.getClientGroupWrapper().get().reply(upStreamMsgContext); upstreamBuff.release(); } else { - upStreamMsgContext = new UpStreamMsgContext(session, msg, header, startTime, taskExecuteTime); + upStreamMsgContext = new UpStreamMsgContext(session, event, header, startTime, taskExecuteTime); session.getClientGroupWrapper().get().send(upStreamMsgContext, sendCallback); } @@ -121,10 +132,10 @@ public EventMeshTcpSendResult send(Header header, Message msg, SendCallback send return new EventMeshTcpSendResult(header.getSeq(), EventMeshTcpSendStatus.SUCCESS, EventMeshTcpSendStatus.SUCCESS.name()); } - private RRCallback initSyncRRCallback(Header header, long startTime, long taskExecuteTime) { - return new RRCallback() { + private RequestReplyCallback initSyncRRCallback(Header header, long startTime, long taskExecuteTime) { + return new RequestReplyCallback() { @Override - public void onSuccess(Message msg) { + public void onSuccess(CloudEvent event) { String seq = header.getSeq(); // TODO: How to assign values here // if (msg instanceof MessageExt) { @@ -133,24 +144,34 @@ public void onSuccess(Message msg) { // msg.putUserProperty(EventMeshConstants.STORE_TIMESTAMP, String.valueOf(((MessageExt) msg) // .getStoreTimestamp())); // } - - msg.getSystemProperties().put(EventMeshConstants.RSP_MQ2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())); - msg.getSystemProperties().put(EventMeshConstants.RSP_RECEIVE_EVENTMESH_IP, session.getEventMeshTCPConfiguration().eventMeshServerIp); + event = CloudEventBuilder.from(event) + .withExtension(EventMeshConstants.RSP_MQ2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .withExtension(EventMeshConstants.RSP_RECEIVE_EVENTMESH_IP, session.getEventMeshTCPConfiguration().eventMeshServerIp) + .build(); session.getClientGroupWrapper().get().getEventMeshTcpMonitor().getMq2EventMeshMsgNum().incrementAndGet(); Command cmd; - if (header.getCommand().equals(Command.REQUEST_TO_SERVER)) { + if (header.getCmd().equals(Command.REQUEST_TO_SERVER)) { cmd = Command.RESPONSE_TO_CLIENT; } else { - messageLogger.error("invalid message|messageHeader={}|msg={}", header, msg); + messageLogger.error("invalid message|messageHeader={}|event={}", header, event); return; } + event = CloudEventBuilder.from(event) + .withExtension(EventMeshConstants.RSP_EVENTMESH2C_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .build(); + String protocolType = Objects.requireNonNull(event.getExtension(Constants.PROTOCOL_TYPE)).toString(); + + ProtocolAdaptor protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + Package pkg = new Package(); - pkg.setHeader(new Header(cmd, OPStatus.SUCCESS.getCode(), null, seq)); - msg.getSystemProperties().put(EventMeshConstants.RSP_EVENTMESH2C_TIMESTAMP, String.valueOf(System.currentTimeMillis())); + +// msg.getSystemProperties().put(EventMeshConstants.RSP_EVENTMESH2C_TIMESTAMP, String.valueOf(System.currentTimeMillis())); try { - pkg.setBody(EventMeshUtil.encodeMessage(msg)); +// pkg.setBody(EventMeshUtil.encodeMessage(msg)); + pkg = (Package) protocolAdaptor.fromCloudEvent(event); pkg.setHeader(new Header(cmd, OPStatus.SUCCESS.getCode(), null, seq)); + pkg.getHeader().putProperty(Constants.PROTOCOL_TYPE, protocolType); } catch (Exception e) { pkg.setHeader(new Header(cmd, OPStatus.FAIL.getCode(), null, seq)); } finally { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/UpStreamMsgContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/UpStreamMsgContext.java index 48be15c936..6a72423ccd 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/UpStreamMsgContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/UpStreamMsgContext.java @@ -17,23 +17,27 @@ package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.send; -import io.openmessaging.api.Message; -import io.openmessaging.api.OnExceptionContext; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.time.DateFormatUtils; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.protocol.tcp.*; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.Header; +import org.apache.eventmesh.common.protocol.tcp.OPStatus; import org.apache.eventmesh.common.protocol.tcp.Package; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.retry.RetryContext; import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.apache.eventmesh.runtime.util.Utils; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.cloudevents.CloudEvent; + public class UpStreamMsgContext extends RetryContext { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -48,10 +52,10 @@ public class UpStreamMsgContext extends RetryContext { private long taskExecuteTime; - public UpStreamMsgContext(Session session, Message msg, Header header, long startTime, long taskExecuteTime) { + public UpStreamMsgContext(Session session, CloudEvent event, Header header, long startTime, long taskExecuteTime) { this.seq = header.getSeq(); this.session = session; - this.msgExt = msg; + this.event = event; this.header = header; this.startTime = startTime; this.taskExecuteTime = taskExecuteTime; @@ -61,8 +65,8 @@ public Session getSession() { return session; } - public Message getMsg() { - return msgExt; + public CloudEvent getEvent() { + return event; } public long getCreateTime() { @@ -72,27 +76,28 @@ public long getCreateTime() { @Override public String toString() { return "UpStreamMsgContext{seq=" + seq - + ",topic=" + msgExt.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION) - + ",client=" + session.getClient() - + ",retryTimes=" + retryTimes - + ",createTime=" + DateFormatUtils.format(createTime, EventMeshConstants.DATE_FORMAT) + "}" - + ",executeTime=" + DateFormatUtils.format(executeTime, EventMeshConstants.DATE_FORMAT); + + ",topic=" + event.getSubject() + + ",client=" + session.getClient() + + ",retryTimes=" + retryTimes + + ",createTime=" + DateFormatUtils.format(createTime, EventMeshConstants.DATE_FORMAT) + "}" + + ",executeTime=" + DateFormatUtils.format(executeTime, EventMeshConstants.DATE_FORMAT); } @Override public void retry() { - logger.info("retry upStream msg start,seq:{},retryTimes:{},bizSeq:{}", this.seq, this.retryTimes, EventMeshUtil.getMessageBizSeq(this.msgExt)); + logger.info("retry upStream msg start,seq:{},retryTimes:{},bizSeq:{}", this.seq, this.retryTimes, + EventMeshUtil.getMessageBizSeq(this.event)); try { - Command replyCmd = getReplyCmd(header.getCommand()); + Command replyCmd = getReplyCmd(header.getCmd()); long sendTime = System.currentTimeMillis(); - EventMeshMessage eventMeshMessage = EventMeshUtil.encodeMessage(msgExt); - EventMeshTcpSendResult sendStatus = session.upstreamMsg(header, msgExt, - createSendCallback(replyCmd, taskExecuteTime, eventMeshMessage), startTime, taskExecuteTime); + + EventMeshTcpSendResult sendStatus = session.upstreamMsg(header, event, + createSendCallback(replyCmd, taskExecuteTime, event), startTime, taskExecuteTime); if (StringUtils.equals(EventMeshTcpSendStatus.SUCCESS.name(), sendStatus.getSendStatus().name())) { - logger.info("pkg|eventMesh2mq|cmd={}|Msg={}|user={}|wait={}ms|cost={}ms", header.getCommand(), EventMeshUtil.printMqMessage - (eventMeshMessage), session.getClient(), taskExecuteTime - startTime, sendTime - startTime); + logger.info("pkg|eventMesh2mq|cmd={}|event={}|user={}|wait={}ms|cost={}ms", header.getCmd(), event, + session.getClient(), taskExecuteTime - startTime, sendTime - startTime); } else { throw new Exception(sendStatus.getDetail()); } @@ -101,7 +106,7 @@ public void retry() { } } - protected SendCallback createSendCallback(Command replyCmd, long taskExecuteTime, EventMeshMessage eventMeshMessage) { + protected SendCallback createSendCallback(Command replyCmd, long taskExecuteTime, CloudEvent event) { final long createTime = System.currentTimeMillis(); Package msg = new Package(); @@ -110,11 +115,11 @@ protected SendCallback createSendCallback(Command replyCmd, long taskExecuteTime public void onSuccess(SendResult sendResult) { session.getSender().getUpstreamBuff().release(); logger.info("upstreamMsg message success|user={}|callback cost={}", session.getClient(), - String.valueOf(System.currentTimeMillis() - createTime)); + String.valueOf(System.currentTimeMillis() - createTime)); if (replyCmd.equals(Command.BROADCAST_MESSAGE_TO_SERVER_ACK) || replyCmd.equals(Command - .ASYNC_MESSAGE_TO_SERVER_ACK)) { + .ASYNC_MESSAGE_TO_SERVER_ACK)) { msg.setHeader(new Header(replyCmd, OPStatus.SUCCESS.getCode(), OPStatus.SUCCESS.getDesc(), seq)); - msg.setBody(eventMeshMessage); + msg.setBody(event); Utils.writeAndFlush(msg, startTime, taskExecuteTime, session.getContext(), session); } } @@ -125,15 +130,16 @@ public void onException(OnExceptionContext context) { // retry UpStreamMsgContext upStreamMsgContext = new UpStreamMsgContext( - session, EventMeshUtil.decodeMessage(eventMeshMessage), header, startTime, taskExecuteTime); + session, event, header, startTime, taskExecuteTime); upStreamMsgContext.delay(10000); session.getClientGroupWrapper().get().getEventMeshTcpRetryer().pushRetry(upStreamMsgContext); session.getSender().failMsgCount.incrementAndGet(); - logger.error("upstreamMsg mq message error|user={}|callback cost={}, errMsg={}", session.getClient(), String.valueOf + logger.error("upstreamMsg mq message error|user={}|callback cost={}, errMsg={}", session.getClient(), + String.valueOf (System.currentTimeMillis() - createTime), new Exception(context.getException())); msg.setHeader(new Header(replyCmd, OPStatus.FAIL.getCode(), context.getException().toString(), seq)); - msg.setBody(eventMeshMessage); + msg.setBody(event); Utils.writeAndFlush(msg, startTime, taskExecuteTime, session.getContext(), session); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/GoodbyeTask.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/GoodbyeTask.java index 67c0d5cf84..ed24ef242e 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/GoodbyeTask.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/GoodbyeTask.java @@ -19,8 +19,6 @@ import static org.apache.eventmesh.common.protocol.tcp.Command.CLIENT_GOODBYE_RESPONSE; -import io.netty.channel.ChannelHandlerContext; - import org.apache.eventmesh.common.protocol.tcp.Command; import org.apache.eventmesh.common.protocol.tcp.Header; import org.apache.eventmesh.common.protocol.tcp.OPStatus; @@ -29,6 +27,8 @@ import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcp2Client; import org.apache.eventmesh.runtime.util.Utils; +import io.netty.channel.ChannelHandlerContext; + public class GoodbyeTask extends AbstractTask { public GoodbyeTask(Package pkg, ChannelHandlerContext ctx, long startTime, EventMeshTCPServer eventMeshTCPServer) { @@ -40,16 +40,17 @@ public void run() { long taskExecuteTime = System.currentTimeMillis(); Package msg = new Package(); try { - if (pkg.getHeader().getCommand() == Command.SERVER_GOODBYE_RESPONSE) { + if (pkg.getHeader().getCmd() == Command.SERVER_GOODBYE_RESPONSE) { logger.info("client|address={}| has reject ", session.getContext().channel().remoteAddress()); } else { - msg.setHeader(new Header(CLIENT_GOODBYE_RESPONSE, OPStatus.SUCCESS.getCode(), OPStatus.SUCCESS.getDesc(), pkg.getHeader().getSeq - ())); + msg.setHeader( + new Header(CLIENT_GOODBYE_RESPONSE, OPStatus.SUCCESS.getCode(), OPStatus.SUCCESS.getDesc(), + pkg.getHeader().getSeq())); } } catch (Exception e) { logger.error("GoodbyeTask failed|user={}|errMsg={}", session.getClient(), e); msg.setHeader(new Header(CLIENT_GOODBYE_RESPONSE, OPStatus.FAIL.getCode(), e.getStackTrace().toString(), pkg - .getHeader().getSeq())); + .getHeader().getSeq())); } finally { this.eventMeshTCPServer.getScheduler().submit(new Runnable() { @Override @@ -59,6 +60,7 @@ public void run() { }); //session.write2Client(msg); } - EventMeshTcp2Client.closeSessionIfTimeout(this.eventMeshTCPServer,session, eventMeshTCPServer.getClientSessionGroupMapping()); + EventMeshTcp2Client + .closeSessionIfTimeout(this.eventMeshTCPServer, session, eventMeshTCPServer.getClientSessionGroupMapping()); } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/HelloTask.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/HelloTask.java index df4a6062b4..10e8f1ad41 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/HelloTask.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/HelloTask.java @@ -55,7 +55,7 @@ public void run() { UserAgent user = (UserAgent) pkg.getBody(); try { //do acl check in connect - if(eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshServerSecurityEnable){ + if (eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshServerSecurityEnable) { String remoteAddr = RemotingHelper.parseChannelRemoteAddr(ctx.channel()); Acl.doAclCheckInTcpConnect(remoteAddr, user, HELLO_REQUEST.value()); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageAckTask.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageAckTask.java index 8902e47431..f5e670e2b4 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageAckTask.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageAckTask.java @@ -39,7 +39,7 @@ public MessageAckTask(Package pkg, ChannelHandlerContext ctx, long startTime, Ev public void run() { long taskExecuteTime = System.currentTimeMillis(); String seq = pkg.getHeader().getSeq(); - Command cmd = pkg.getHeader().getCommand(); + Command cmd = pkg.getHeader().getCmd(); if (seq == null) { logger.error("MessageAckTask failed, seq cannot be null|user={}", session.getClient()); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageTransferTask.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageTransferTask.java index b0c79fa4a9..c5d5d1abd4 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageTransferTask.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageTransferTask.java @@ -17,30 +17,40 @@ package org.apache.eventmesh.runtime.core.protocol.tcp.client.task; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelHandlerContext; -import io.openmessaging.api.OnExceptionContext; -import io.openmessaging.api.SendCallback; -import io.openmessaging.api.SendResult; -import org.apache.commons.lang3.StringUtils; +import static org.apache.eventmesh.common.protocol.tcp.Command.RESPONSE_TO_SERVER; + +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.Header; +import org.apache.eventmesh.common.protocol.tcp.OPStatus; import org.apache.eventmesh.common.protocol.tcp.Package; -import org.apache.eventmesh.common.protocol.tcp.*; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.acl.Acl; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.send.EventMeshTcpSendResult; import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.send.EventMeshTcpSendStatus; import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.send.UpStreamMsgContext; -import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.apache.eventmesh.runtime.util.RemotingHelper; import org.apache.eventmesh.runtime.util.Utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import org.apache.commons.lang3.StringUtils; import java.util.concurrent.TimeUnit; -import static org.apache.eventmesh.common.protocol.tcp.Command.RESPONSE_TO_SERVER; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; public class MessageTransferTask extends AbstractTask { @@ -48,77 +58,101 @@ public class MessageTransferTask extends AbstractTask { private final int TRY_PERMIT_TIME_OUT = 5; - public MessageTransferTask(Package pkg, ChannelHandlerContext ctx, long startTime, EventMeshTCPServer eventMeshTCPServer) { + public MessageTransferTask(Package pkg, ChannelHandlerContext ctx, long startTime, + EventMeshTCPServer eventMeshTCPServer) { super(pkg, ctx, startTime, eventMeshTCPServer); } @Override public void run() { long taskExecuteTime = System.currentTimeMillis(); - Command cmd = pkg.getHeader().getCommand(); + Command cmd = pkg.getHeader().getCmd(); Command replyCmd = getReplyCmd(cmd); + String protocolType = "EventMeshMessage"; + if (pkg.getHeader().getProperties() != null && pkg.getHeader().getProperty(Constants.PROTOCOL_TYPE) != null) { + protocolType = (String) pkg.getHeader().getProperty(Constants.PROTOCOL_TYPE); + } + ProtocolAdaptor protocolAdaptor = + ProtocolPluginFactory.getProtocolAdaptor(protocolType); Package msg = new Package(); - EventMeshMessage eventMeshMessage = (EventMeshMessage) pkg.getBody(); + +// EventMeshMessage eventMeshMessage = (EventMeshMessage) pkg.getBody(); int retCode = 0; EventMeshTcpSendResult sendStatus; + CloudEvent event = null; try { - if (eventMeshMessage == null) { - throw new Exception("eventMeshMessage is null"); + event = protocolAdaptor.toCloudEvent(pkg); + if (event == null) { + throw new Exception("event is null"); } //do acl check in sending msg - if(eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshServerSecurityEnable){ + if (eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshServerSecurityEnable) { String remoteAddr = RemotingHelper.parseChannelRemoteAddr(ctx.channel()); - Acl.doAclCheckInTcpSend(remoteAddr, session.getClient(), eventMeshMessage.getTopic(), cmd.value()); + Acl.doAclCheckInTcpSend(remoteAddr, session.getClient(), event.getSubject(), cmd.value()); } if (eventMeshTCPServer.getRateLimiter().tryAcquire(TRY_PERMIT_TIME_OUT, TimeUnit.MILLISECONDS)) { synchronized (session) { long sendTime = System.currentTimeMillis(); - addTimestamp(eventMeshMessage, cmd, sendTime); + event = addTimestamp(event, cmd, sendTime); - sendStatus = session.upstreamMsg(pkg.getHeader(), EventMeshUtil.decodeMessage(eventMeshMessage), createSendCallback(replyCmd, taskExecuteTime, eventMeshMessage), startTime, taskExecuteTime); + sendStatus = session + .upstreamMsg(pkg.getHeader(), event, createSendCallback(replyCmd, taskExecuteTime, event), + startTime, taskExecuteTime); if (StringUtils.equals(EventMeshTcpSendStatus.SUCCESS.name(), sendStatus.getSendStatus().name())) { - messageLogger.info("pkg|eventMesh2mq|cmd={}|Msg={}|user={}|wait={}ms|cost={}ms", cmd, EventMeshUtil.printMqMessage - (eventMeshMessage), session.getClient(), taskExecuteTime - startTime, sendTime - startTime); + messageLogger.info("pkg|eventMesh2mq|cmd={}|Msg={}|user={}|wait={}ms|cost={}ms", cmd, event, + session.getClient(), taskExecuteTime - startTime, sendTime - startTime); } else { throw new Exception(sendStatus.getDetail()); } } - }else{ - msg.setHeader(new Header(replyCmd, OPStatus.FAIL.getCode(), "Tps overload, global flow control", pkg.getHeader().getSeq())); + } else { + msg.setHeader(new Header(replyCmd, OPStatus.FAIL.getCode(), "Tps overload, global flow control", + pkg.getHeader().getSeq())); ctx.writeAndFlush(msg).addListener( - new ChannelFutureListener() { - @Override - public void operationComplete(ChannelFuture future) throws Exception { - Utils.logSucceedMessageFlow(msg, session.getClient(), startTime, taskExecuteTime); - } + new ChannelFutureListener() { + @Override + public void operationComplete(ChannelFuture future) throws Exception { + Utils.logSucceedMessageFlow(msg, session.getClient(), startTime, taskExecuteTime); } + } ); - logger.warn("======Tps overload, global flow control, rate:{}! PLEASE CHECK!========", eventMeshTCPServer.getRateLimiter().getRate()); + logger.warn("======Tps overload, global flow control, rate:{}! PLEASE CHECK!========", + eventMeshTCPServer.getRateLimiter().getRate()); return; } } catch (Exception e) { - logger.error("MessageTransferTask failed|cmd={}|Msg={}|user={}|errMsg={}", cmd, eventMeshMessage, session.getClient(), e); + logger + .error("MessageTransferTask failed|cmd={}|event={}|user={}|errMsg={}", cmd, event, session.getClient(), + e); if (!cmd.equals(RESPONSE_TO_SERVER)) { - msg.setHeader(new Header(replyCmd, OPStatus.FAIL.getCode(), e.getStackTrace().toString(), pkg.getHeader() + msg.setHeader( + new Header(replyCmd, OPStatus.FAIL.getCode(), e.getStackTrace().toString(), pkg.getHeader() .getSeq())); Utils.writeAndFlush(msg, startTime, taskExecuteTime, session.getContext(), session); } } } - private void addTimestamp(EventMeshMessage eventMeshMessage, Command cmd, long sendTime) { + private CloudEvent addTimestamp(CloudEvent event, Command cmd, long sendTime) { if (cmd.equals(RESPONSE_TO_SERVER)) { - eventMeshMessage.getProperties().put(EventMeshConstants.RSP_C2EVENTMESH_TIMESTAMP, String.valueOf(startTime)); - eventMeshMessage.getProperties().put(EventMeshConstants.RSP_EVENTMESH2MQ_TIMESTAMP, String.valueOf(sendTime)); - eventMeshMessage.getProperties().put(EventMeshConstants.RSP_SEND_EVENTMESH_IP, eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshServerIp); + event = CloudEventBuilder.from(event) + .withExtension(EventMeshConstants.RSP_C2EVENTMESH_TIMESTAMP, String.valueOf(startTime)) + .withExtension(EventMeshConstants.RSP_EVENTMESH2MQ_TIMESTAMP, String.valueOf(sendTime)) + .withExtension(EventMeshConstants.RSP_SEND_EVENTMESH_IP, + eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshServerIp) + .build(); } else { - eventMeshMessage.getProperties().put(EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP, String.valueOf(startTime)); - eventMeshMessage.getProperties().put(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, String.valueOf(sendTime)); - eventMeshMessage.getProperties().put(EventMeshConstants.REQ_SEND_EVENTMESH_IP, eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshServerIp); + event = CloudEventBuilder.from(event) + .withExtension(EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP, String.valueOf(startTime)) + .withExtension(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, String.valueOf(sendTime)) + .withExtension(EventMeshConstants.REQ_SEND_EVENTMESH_IP, + eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshServerIp) + .build(); } + return event; } private Command getReplyCmd(Command cmd) { @@ -134,7 +168,7 @@ private Command getReplyCmd(Command cmd) { } } - protected SendCallback createSendCallback(Command replyCmd, long taskExecuteTime, EventMeshMessage eventMeshMessage) { + protected SendCallback createSendCallback(Command replyCmd, long taskExecuteTime, CloudEvent event) { final long createTime = System.currentTimeMillis(); Package msg = new Package(); @@ -143,11 +177,12 @@ protected SendCallback createSendCallback(Command replyCmd, long taskExecuteTime public void onSuccess(SendResult sendResult) { session.getSender().getUpstreamBuff().release(); messageLogger.info("upstreamMsg message success|user={}|callback cost={}", session.getClient(), - String.valueOf(System.currentTimeMillis() - createTime)); + String.valueOf(System.currentTimeMillis() - createTime)); if (replyCmd.equals(Command.BROADCAST_MESSAGE_TO_SERVER_ACK) || replyCmd.equals(Command - .ASYNC_MESSAGE_TO_SERVER_ACK)) { - msg.setHeader(new Header(replyCmd, OPStatus.SUCCESS.getCode(), OPStatus.SUCCESS.getDesc(), pkg.getHeader().getSeq())); - msg.setBody(eventMeshMessage); + .ASYNC_MESSAGE_TO_SERVER_ACK)) { + msg.setHeader(new Header(replyCmd, OPStatus.SUCCESS.getCode(), OPStatus.SUCCESS.getDesc(), + pkg.getHeader().getSeq())); + msg.setBody(event); Utils.writeAndFlush(msg, startTime, taskExecuteTime, session.getContext(), session); } } @@ -158,28 +193,20 @@ public void onException(OnExceptionContext context) { // retry UpStreamMsgContext upStreamMsgContext = new UpStreamMsgContext( - session, EventMeshUtil.decodeMessage(eventMeshMessage), pkg.getHeader(), startTime, taskExecuteTime); + session, event, pkg.getHeader(), startTime, taskExecuteTime); upStreamMsgContext.delay(10000); session.getClientGroupWrapper().get().getEventMeshTcpRetryer().pushRetry(upStreamMsgContext); session.getSender().failMsgCount.incrementAndGet(); - messageLogger.error("upstreamMsg mq message error|user={}|callback cost={}, errMsg={}", session.getClient(), String.valueOf + messageLogger + .error("upstreamMsg mq message error|user={}|callback cost={}, errMsg={}", session.getClient(), (System.currentTimeMillis() - createTime), new Exception(context.getException())); - msg.setHeader(new Header(replyCmd, OPStatus.FAIL.getCode(), context.getException().toString(), pkg.getHeader().getSeq())); - msg.setBody(eventMeshMessage); + msg.setHeader(new Header(replyCmd, OPStatus.FAIL.getCode(), context.getException().toString(), + pkg.getHeader().getSeq())); + msg.setBody(event); Utils.writeAndFlush(msg, startTime, taskExecuteTime, session.getContext(), session); } -// @Override -// public void onException(Throwable e) { -// session.getSender().getUpstreamBuff().release(); -// session.getSender().failMsgCount.incrementAndGet(); -// messageLogger.error("upstreamMsg mq message error|user={}|callback cost={}, errMsg={}", session.getClient(), String.valueOf -// (System.currentTimeMillis() - createTime), new Exception(e)); -// msg.setHeader(new Header(replyCmd, OPStatus.FAIL.getCode(), e.toString(), pkg.getHeader().getSeq())); -// msg.setBody(accessMessage); -// Utils.writeAndFlush(msg, startTime, taskExecuteTime, session.getContext(), session); -// } }; } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/exporter/EventMeshExporter.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/exporter/EventMeshExporter.java new file mode 100644 index 0000000000..abc9cf9fd6 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/exporter/EventMeshExporter.java @@ -0,0 +1,29 @@ +/* + * Licensed 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.eventmesh.runtime.exporter; + +import org.apache.eventmesh.common.config.CommonConfiguration; + +import io.opentelemetry.sdk.trace.export.SpanExporter; + +/** + * different exporters should implement this interface. + */ +public interface EventMeshExporter { + public SpanExporter getSpanExporter(CommonConfiguration configuration); +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/exporter/LogExporter.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/exporter/LogExporter.java new file mode 100644 index 0000000000..b4b11a486d --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/exporter/LogExporter.java @@ -0,0 +1,83 @@ +/* + * Licensed 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.eventmesh.runtime.exporter; + +import java.util.Collection; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.opentelemetry.sdk.common.CompletableResultCode; +import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.trace.data.SpanData; +import io.opentelemetry.sdk.trace.export.SpanExporter; + +/** + * Because the class 'LoggingSpanExporter' in openTelemetry exported garbled code in eventMesh's startUp, + * I override the 'LoggingSpanExporter'. + */ +public class LogExporter implements SpanExporter { + private static final Logger logger = LoggerFactory.getLogger(LogExporter.class); + + @Override + public CompletableResultCode export(Collection spans) { + // We always have 32 + 16 + name + several whitespace, 60 seems like an OK initial guess. + StringBuilder sb = new StringBuilder(60); + for (SpanData span : spans) { + sb.setLength(0); + InstrumentationLibraryInfo instrumentationLibraryInfo = span.getInstrumentationLibraryInfo(); + sb.append("'") + .append(span.getName()) + .append("' : ") + .append(span.getTraceId()) + .append(" ") + .append(span.getSpanId()) + .append(" ") + .append(span.getKind()) + .append(" [tracer: ") + .append(instrumentationLibraryInfo.getName()) + .append(":") + .append( + instrumentationLibraryInfo.getVersion() == null + ? "" + : instrumentationLibraryInfo.getVersion()) + .append("] ") + .append(span.getAttributes()); + logger.info(sb.toString()); + } + return CompletableResultCode.ofSuccess(); + } + + /** + * Flushes the data. + * (i guess it is not necessary for slf4j's log) + * + * @return the result of the operation + */ + @Override + public CompletableResultCode flush() { + CompletableResultCode resultCode = new CompletableResultCode(); + return resultCode.succeed(); + } + + @Override + public CompletableResultCode shutdown() { + return flush(); + } + +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/exporter/ZipkinExporter.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/exporter/ZipkinExporter.java new file mode 100644 index 0000000000..c5b0284be0 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/exporter/ZipkinExporter.java @@ -0,0 +1,46 @@ +/* + * Licensed 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.eventmesh.runtime.exporter; + +import org.apache.eventmesh.common.config.CommonConfiguration; + +import io.opentelemetry.exporter.zipkin.ZipkinSpanExporter; + +/** + * an exporter to export traced data to zipkin. + */ +public class ZipkinExporter implements EventMeshExporter { + private String ip = "localhost"; + + private int port = 9411; + + // Zipkin API Endpoints for uploading spans + private static final String ENDPOINT_V2_SPANS = "/api/v2/spans"; + + private ZipkinSpanExporter zipkinExporter; + + @Override + public ZipkinSpanExporter getSpanExporter(CommonConfiguration configuration) { + ip = configuration.eventMeshServerIp; + port = configuration.eventMeshTraceExportZipkinPort; + String httpUrl = String.format("http://%s:%s", ip, port); + zipkinExporter = + ZipkinSpanExporter.builder().setEndpoint(httpUrl + ENDPOINT_V2_SPANS).build(); + return zipkinExporter; + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/opentelemetry/OpenTelemetryHTTPMetricsExporter.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/opentelemetry/OpenTelemetryHTTPMetricsExporter.java index a94b7e14f9..b3805d2b9d 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/opentelemetry/OpenTelemetryHTTPMetricsExporter.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/opentelemetry/OpenTelemetryHTTPMetricsExporter.java @@ -36,7 +36,7 @@ public OpenTelemetryHTTPMetricsExporter(HTTPMetricsServer httpMetricsServer, Eve this.summaryMetrics = httpMetricsServer.summaryMetrics; } - public void start(){ + public void start() { Meter meter = GlobalMeterProvider.getMeter("apache-eventmesh"); //maxHTTPTPS meter diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/AttributeKeys.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/AttributeKeys.java new file mode 100644 index 0000000000..10214a8aa1 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/AttributeKeys.java @@ -0,0 +1,44 @@ +/* + * Licensed 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.eventmesh.runtime.trace; + +import io.netty.util.AttributeKey; +import io.opentelemetry.context.Context; + +/** + * keys. + */ +public final class AttributeKeys { + public static final AttributeKey WRITE_CONTEXT = + AttributeKey.valueOf(AttributeKeys.class, "passed-context"); + + // this is the context that has the server span + // + // note: this attribute key is also used by ratpack instrumentation + public static final AttributeKey SERVER_CONTEXT = + AttributeKey.valueOf(AttributeKeys.class, "server-span"); + + public static final AttributeKey CLIENT_CONTEXT = + AttributeKey.valueOf(AttributeKeys.class, "client-context"); + + public static final AttributeKey CLIENT_PARENT_CONTEXT = + AttributeKey.valueOf(AttributeKeys.class, "client-parent-context"); + + private AttributeKeys() { + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/OpenTelemetryTraceFactory.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/OpenTelemetryTraceFactory.java new file mode 100644 index 0000000000..ae4ce41d91 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/OpenTelemetryTraceFactory.java @@ -0,0 +1,109 @@ +/* + * Licensed 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.eventmesh.runtime.trace; + +import static io.opentelemetry.api.common.AttributeKey.stringKey; + +import org.apache.eventmesh.common.config.CommonConfiguration; +import org.apache.eventmesh.runtime.exporter.EventMeshExporter; +import org.apache.eventmesh.runtime.exporter.LogExporter; + +import java.util.concurrent.TimeUnit; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator; +import io.opentelemetry.context.propagation.ContextPropagators; +import io.opentelemetry.context.propagation.TextMapPropagator; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.resources.Resource; +import io.opentelemetry.sdk.trace.SdkTracerProvider; +import io.opentelemetry.sdk.trace.SpanProcessor; +import io.opentelemetry.sdk.trace.export.BatchSpanProcessor; +import io.opentelemetry.sdk.trace.export.SpanExporter; + +/** + * create tracer. + */ +public class OpenTelemetryTraceFactory { + private static final Logger logger = LoggerFactory.getLogger(OpenTelemetryTraceFactory.class); + // Name of the service(using the instrumentationName) + private final String serviceName = "eventmesh_trace"; + private OpenTelemetry openTelemetry; + private SpanExporter spanExporter; + private SpanExporter defaultExporter = new LogExporter(); + private SpanProcessor spanProcessor; + + public OpenTelemetryTraceFactory(CommonConfiguration configuration) { + try { + //different spanExporter + String exporterName = configuration.eventMeshTraceExporterType; + //use reflection to get spanExporter + String className = String.format("org.apache.eventmesh.runtime.exporter.%sExporter", exporterName); + EventMeshExporter eventMeshExporter = (EventMeshExporter) Class.forName(className).newInstance(); + spanExporter = eventMeshExporter.getSpanExporter(configuration); + } catch (Exception ex) { + logger.error("fail to set tracer's exporter,due to {}", ex.getMessage()); + //fail to set the exporter in configuration, changing to use the default Exporter + spanExporter = defaultExporter; + logger.info("change to use the default exporter {}", defaultExporter.getClass()); + } + + // Configure the batch spans processor. This span processor exports span in batches. + spanProcessor = BatchSpanProcessor.builder(spanExporter) + // set the maximum batch size to use + .setMaxExportBatchSize(configuration.eventMeshTraceExporterMaxExportSize) + // set the queue size. This must be >= the export batch size + .setMaxQueueSize(configuration.eventMeshTraceExporterMaxQueueSize) + // set the max amount of time an export can run before getting + .setExporterTimeout(configuration.eventMeshTraceExporterExportTimeout, TimeUnit.SECONDS) + // set time between two different exports + .setScheduleDelay(configuration.eventMeshTraceExporterExportInterval, TimeUnit.SECONDS) + .build(); + + //set the trace service's name + Resource serviceNameResource = + Resource.create(Attributes.of(stringKey("service.name"), serviceName)); + + SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder() + .addSpanProcessor(spanProcessor) + .setResource(Resource.getDefault().merge(serviceNameResource)) + .build(); + + openTelemetry = OpenTelemetrySdk.builder() + .setPropagators(ContextPropagators.create(W3CTraceContextPropagator.getInstance())) + .setTracerProvider(sdkTracerProvider) + .build(); + + Runtime.getRuntime().addShutdownHook(new Thread(sdkTracerProvider::close)); + } + + //Gets or creates a named tracer instance + public Tracer getTracer(String instrumentationName) { + return openTelemetry.getTracer(instrumentationName); + } + + //to inject or extract span context + public TextMapPropagator getTextMapPropagator() { + return openTelemetry.getPropagators().getTextMapPropagator(); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/SpanKey.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/SpanKey.java new file mode 100644 index 0000000000..3fb285d14d --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/SpanKey.java @@ -0,0 +1,52 @@ +/* + * Licensed 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.eventmesh.runtime.trace; + +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.context.ContextKey; + +/** + * Makes span keys for specific instrumentation accessible to enrich and suppress spans. + */ +public final class SpanKey { + // server span key + public static final ContextKey SERVER_KEY = + ContextKey.named("opentelemetry-traces-span-key-server"); + + // client span keys + public static final ContextKey HTTP_CLIENT_KEY = + ContextKey.named("opentelemetry-traces-span-key-http"); + public static final ContextKey RPC_CLIENT_KEY = + ContextKey.named("opentelemetry-traces-span-key-rpc"); + public static final ContextKey DB_CLIENT_KEY = + ContextKey.named("opentelemetry-traces-span-key-db"); + + // this is used instead of above, depending on the configuration value for + // otel.instrumentation.experimental.outgoing-span-suppression-by-type + public static final ContextKey CLIENT_KEY = + ContextKey.named("opentelemetry-traces-span-key-client"); + + // producer & consumer (messaging) span keys + public static final ContextKey PRODUCER_KEY = + ContextKey.named("opentelemetry-traces-span-key-producer"); + public static final ContextKey CONSUMER_RECEIVE_KEY = + ContextKey.named("opentelemetry-traces-span-key-consumer-receive"); + public static final ContextKey CONSUMER_PROCESS_KEY = + ContextKey.named("opentelemetry-traces-span-key-consumer-process"); +} + diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/EventMeshUtil.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/EventMeshUtil.java index eaa7be58ad..22400f7c3d 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/EventMeshUtil.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/EventMeshUtil.java @@ -17,9 +17,6 @@ package org.apache.eventmesh.runtime.util; - -import static org.apache.eventmesh.runtime.util.OMSUtil.isOMSHeader; - import java.net.Inet6Address; import java.net.InetAddress; import java.net.NetworkInterface; @@ -28,6 +25,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.Set; @@ -39,12 +37,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import io.openmessaging.api.Message; +import io.cloudevents.CloudEvent; import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.RandomStringUtil; -import org.apache.eventmesh.common.ThreadUtil; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.runtime.constants.EventMeshConstants; @@ -59,14 +57,14 @@ public class EventMeshUtil { private final static Logger tcpLogger = LoggerFactory.getLogger("tcpMonitor"); public static String buildPushMsgSeqNo() { - return StringUtils.rightPad(String.valueOf(System.currentTimeMillis()), 6) + RandomStringUtil.generateNum(4); + return StringUtils.rightPad(String.valueOf(System.currentTimeMillis()), 6) + RandomStringUtils.generateNum(4); } public static String buildMeshClientID(String clientGroup, String meshCluster) { return StringUtils.trim(clientGroup) + "(" + StringUtils.trim(meshCluster) + ")" + "-" + EventMeshVersion.getCurrentVersionDesc() - + "-" + ThreadUtil.getPID(); + + "-" + ThreadUtils.getPID(); } public static String buildMeshTcpClientID(String clientSysId, String purpose, String meshCluster) { @@ -74,7 +72,7 @@ public static String buildMeshTcpClientID(String clientSysId, String purpose, St + "-" + StringUtils.trim(purpose) + "-" + StringUtils.trim(meshCluster) + "-" + EventMeshVersion.getCurrentVersionDesc() - + "-" + ThreadUtil.getPID(); + + "-" + ThreadUtils.getPID(); } public static String buildClientGroup(String systemId) { @@ -139,16 +137,24 @@ public static String printMqMessage(EventMeshMessage eventMeshMessage) { return result; } - public static String getMessageBizSeq(Message msg) { - Properties properties = msg.getSystemProperties(); + public static String getMessageBizSeq(CloudEvent event) { - String keys = properties.getProperty(EventMeshConstants.KEYS_UPPERCASE); + String keys = (String) event.getExtension(EventMeshConstants.KEYS_UPPERCASE); if (!StringUtils.isNotBlank(keys)) { - keys = properties.getProperty(EventMeshConstants.KEYS_LOWERCASE); + keys = (String) event.getExtension(EventMeshConstants.KEYS_LOWERCASE); } return keys; } + public static Map getEventProp(CloudEvent event) { + Set extensionSet = event.getExtensionNames(); + Map prop = new HashMap<>(); + for (String extensionKey : extensionSet) { + prop.put(extensionKey, event.getExtension(extensionKey).toString()); + } + return prop; + } + // public static org.apache.rocketmq.common.message.Message decodeMessage(AccessMessage accessMessage) { // org.apache.rocketmq.common.message.Message msg = new org.apache.rocketmq.common.message.Message(); // msg.setTopic(accessMessage.getTopic()); @@ -160,28 +166,28 @@ public static String getMessageBizSeq(Message msg) { // return msg; // } - public static Message decodeMessage(EventMeshMessage eventMeshMessage) { - Message omsMsg = new Message(); - omsMsg.setBody(eventMeshMessage.getBody().getBytes()); - omsMsg.setTopic(eventMeshMessage.getTopic()); - Properties systemProperties = new Properties(); - Properties userProperties = new Properties(); - - final Set> entries = eventMeshMessage.getProperties().entrySet(); - - for (final Map.Entry entry : entries) { - if (isOMSHeader(entry.getKey())) { - systemProperties.put(entry.getKey(), entry.getValue()); - } else { - userProperties.put(entry.getKey(), entry.getValue()); - } - } - - systemProperties.put(Constants.PROPERTY_MESSAGE_DESTINATION, eventMeshMessage.getTopic()); - omsMsg.setSystemProperties(systemProperties); - omsMsg.setUserProperties(userProperties); - return omsMsg; - } +// public static Message decodeMessage(EventMeshMessage eventMeshMessage) { +// Message omsMsg = new Message(); +// omsMsg.setBody(eventMeshMessage.getBody().getBytes()); +// omsMsg.setTopic(eventMeshMessage.getTopic()); +// Properties systemProperties = new Properties(); +// Properties userProperties = new Properties(); +// +// final Set> entries = eventMeshMessage.getProperties().entrySet(); +// +// for (final Map.Entry entry : entries) { +// if (isOMSHeader(entry.getKey())) { +// systemProperties.put(entry.getKey(), entry.getValue()); +// } else { +// userProperties.put(entry.getKey(), entry.getValue()); +// } +// } +// +// systemProperties.put(Constants.PROPERTY_MESSAGE_DESTINATION, eventMeshMessage.getTopic()); +// omsMsg.setSystemProperties(systemProperties); +// omsMsg.setUserProperties(userProperties); +// return omsMsg; +// } // public static AccessMessage encodeMessage(org.apache.rocketmq.common.message.Message msg) throws Exception { // AccessMessage accessMessage = new AccessMessage(); @@ -193,42 +199,42 @@ public static Message decodeMessage(EventMeshMessage eventMeshMessage) { // return accessMessage; // } - public static EventMeshMessage encodeMessage(Message omsMessage) throws Exception { - - EventMeshMessage eventMeshMessage = new EventMeshMessage(); - eventMeshMessage.setBody(new String(omsMessage.getBody(), StandardCharsets.UTF_8)); - - Properties sysHeaders = omsMessage.getSystemProperties(); - Properties userHeaders = omsMessage.getUserProperties(); - - //All destinations in RocketMQ use Topic - eventMeshMessage.setTopic(sysHeaders.getProperty(Constants.PROPERTY_MESSAGE_DESTINATION)); - - if (sysHeaders.containsKey("START_TIME")) { - long deliverTime; - if (StringUtils.isBlank(sysHeaders.getProperty("START_TIME"))) { - deliverTime = 0; - } else { - deliverTime = Long.parseLong(sysHeaders.getProperty("START_TIME")); - } - - if (deliverTime > 0) { -// rmqMessage.putUserProperty(RocketMQConstants.START_DELIVER_TIME, String.valueOf(deliverTime)); - eventMeshMessage.getProperties().put("START_TIME", String.valueOf(deliverTime)); - } - } - - for (String key : userHeaders.stringPropertyNames()) { - eventMeshMessage.getProperties().put(key, userHeaders.getProperty(key)); - } - - //System headers has a high priority - for (String key : sysHeaders.stringPropertyNames()) { - eventMeshMessage.getProperties().put(key, sysHeaders.getProperty(key)); - } - - return eventMeshMessage; - } +// public static EventMeshMessage encodeMessage(Message omsMessage) throws Exception { +// +// EventMeshMessage eventMeshMessage = new EventMeshMessage(); +// eventMeshMessage.setBody(new String(omsMessage.getBody(), StandardCharsets.UTF_8)); +// +// Properties sysHeaders = omsMessage.getSystemProperties(); +// Properties userHeaders = omsMessage.getUserProperties(); +// +// //All destinations in RocketMQ use Topic +// eventMeshMessage.setTopic(sysHeaders.getProperty(Constants.PROPERTY_MESSAGE_DESTINATION)); +// +// if (sysHeaders.containsKey("START_TIME")) { +// long deliverTime; +// if (StringUtils.isBlank(sysHeaders.getProperty("START_TIME"))) { +// deliverTime = 0; +// } else { +// deliverTime = Long.parseLong(sysHeaders.getProperty("START_TIME")); +// } +// +// if (deliverTime > 0) { +//// rmqMessage.putUserProperty(RocketMQConstants.START_DELIVER_TIME, String.valueOf(deliverTime)); +// eventMeshMessage.getProperties().put("START_TIME", String.valueOf(deliverTime)); +// } +// } +// +// for (String key : userHeaders.stringPropertyNames()) { +// eventMeshMessage.getProperties().put(key, userHeaders.getProperty(key)); +// } +// +// //System headers has a high priority +// for (String key : sysHeaders.stringPropertyNames()) { +// eventMeshMessage.getProperties().put(key, sysHeaders.getProperty(key)); +// } +// +// return eventMeshMessage; +// } public static String getLocalAddr() { //priority of networkInterface when generating client ip diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/OMSUtil.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/OMSUtil.java deleted file mode 100644 index 32e310f84e..0000000000 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/OMSUtil.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to 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. Apache Software Foundation (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.eventmesh.runtime.util; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import io.openmessaging.api.Message; -import io.openmessaging.api.OMSBuiltinKeys; - -public class OMSUtil { - - public static boolean isOMSHeader(String value) { - for (Field field : OMSBuiltinKeys.class.getDeclaredFields()) { - try { - if (field.get(OMSBuiltinKeys.class).equals(value)) { - return true; - } - } catch (IllegalAccessException e) { - return false; - } - } - return false; - } - -// public static Properties convertKeyValue2Prop(KeyValue keyValue){ -// Properties properties = new Properties(); -// for (String key : keyValue.keySet()){ -// properties.put(key, keyValue.getString(key)); -// } -// return properties; -// } - - @SuppressWarnings("unchecked") - public static Map combineProp(Properties p1, Properties p2) { - Properties properties = new Properties(); - properties.putAll(p1); - properties.putAll(p2); - - return new HashMap<>((Map) properties); - } - - public static Map getMessageProp(Message message) { - Properties p1 = message.getSystemProperties(); - Properties p2 = message.getUserProperties(); - return combineProp(p1, p2); - } - -} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/Utils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/Utils.java index cf97d05a8f..fb3ee4bc1f 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/Utils.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/Utils.java @@ -17,24 +17,26 @@ package org.apache.eventmesh.runtime.util; -import java.util.Map; - -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelHandlerContext; - -import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; import org.apache.eventmesh.common.protocol.tcp.Package; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.SessionState; + +import org.apache.commons.lang3.StringUtils; + +import java.util.Map; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; + public class Utils { - private final static Logger logger = LoggerFactory.getLogger(Utils.class); + private final static Logger logger = LoggerFactory.getLogger(Utils.class); private final static Logger messageLogger = LoggerFactory.getLogger("message"); /** @@ -45,29 +47,32 @@ public class Utils { * @param ctx * @param session */ - public static void writeAndFlush(final Package pkg, long startTime, long taskExecuteTime, ChannelHandlerContext ctx, Session - session) { + public static void writeAndFlush(final Package pkg, long startTime, long taskExecuteTime, ChannelHandlerContext ctx, + Session + session) { try { UserAgent user = session == null ? null : session.getClient(); if (session != null && session.getSessionState().equals(SessionState.CLOSED)) { - logFailedMessageFlow(pkg, user, startTime, taskExecuteTime, new Exception("the session has been closed")); + logFailedMessageFlow(pkg, user, startTime, taskExecuteTime, + new Exception("the session has been closed")); return; } ctx.writeAndFlush(pkg).addListener( - new ChannelFutureListener() { - @Override - public void operationComplete(ChannelFuture future) throws Exception { - if (!future.isSuccess()) { - logFailedMessageFlow(future, pkg, user, startTime, taskExecuteTime); - } else { - logSucceedMessageFlow(pkg, user, startTime, taskExecuteTime); - - if (session != null) { - session.getClientGroupWrapper().get().getEventMeshTcpMonitor().getEventMesh2clientMsgNum().incrementAndGet(); - } + new ChannelFutureListener() { + @Override + public void operationComplete(ChannelFuture future) throws Exception { + if (!future.isSuccess()) { + logFailedMessageFlow(future, pkg, user, startTime, taskExecuteTime); + } else { + logSucceedMessageFlow(pkg, user, startTime, taskExecuteTime); + + if (session != null) { + session.getClientGroupWrapper().get().getEventMeshTcpMonitor() + .getEventMesh2clientMsgNum().incrementAndGet(); } } } + } ); } catch (Exception e) { logger.error("exception while sending message to client", e); @@ -82,22 +87,27 @@ public void operationComplete(ChannelFuture future) throws Exception { * @param user * @param startTime */ - public static void logFailedMessageFlow(ChannelFuture future, Package pkg, UserAgent user, long startTime, long taskExecuteTime) { + public static void logFailedMessageFlow(ChannelFuture future, Package pkg, UserAgent user, long startTime, + long taskExecuteTime) { logFailedMessageFlow(pkg, user, startTime, taskExecuteTime, future.cause()); } - private static void logFailedMessageFlow(Package pkg, UserAgent user, long startTime, long taskExecuteTime, Throwable e) { + private static void logFailedMessageFlow(Package pkg, UserAgent user, long startTime, long taskExecuteTime, + Throwable e) { if (pkg.getBody() instanceof EventMeshMessage) { - messageLogger.error("pkg|eventMesh2c|failed|cmd={}|mqMsg={}|user={}|wait={}ms|cost={}ms|errMsg={}", pkg.getHeader().getCommand(), - printMqMessage((EventMeshMessage) pkg.getBody()), user, taskExecuteTime - startTime, System.currentTimeMillis() - startTime, e); + messageLogger.error("pkg|eventMesh2c|failed|cmd={}|mqMsg={}|user={}|wait={}ms|cost={}ms|errMsg={}", + pkg.getHeader().getCmd(), + printMqMessage((EventMeshMessage) pkg.getBody()), user, taskExecuteTime - startTime, + System.currentTimeMillis() - startTime, e); } else { - messageLogger.error("pkg|eventMesh2c|failed|cmd={}|pkg={}|user={}|wait={}ms|cost={}ms|errMsg={}", pkg.getHeader().getCommand(), - pkg, user, taskExecuteTime - startTime, System.currentTimeMillis() - startTime, e); + messageLogger.error("pkg|eventMesh2c|failed|cmd={}|pkg={}|user={}|wait={}ms|cost={}ms|errMsg={}", + pkg.getHeader().getCmd(), + pkg, user, taskExecuteTime - startTime, System.currentTimeMillis() - startTime, e); } } /** - * print the message flow of successful sending + * print the message flow of successful sending. * * @param pkg * @param user @@ -105,47 +115,16 @@ private static void logFailedMessageFlow(Package pkg, UserAgent user, long start */ public static void logSucceedMessageFlow(Package pkg, UserAgent user, long startTime, long taskExecuteTime) { if (pkg.getBody() instanceof EventMeshMessage) { - messageLogger.info("pkg|eventMesh2c|cmd={}|mqMsg={}|user={}|wait={}ms|cost={}ms", pkg.getHeader().getCommand(), - printMqMessage((EventMeshMessage) pkg.getBody()), user, taskExecuteTime - startTime, System.currentTimeMillis() - startTime); + messageLogger.info("pkg|eventMesh2c|cmd={}|mqMsg={}|user={}|wait={}ms|cost={}ms", pkg.getHeader().getCmd(), + printMqMessage((EventMeshMessage) pkg.getBody()), user, taskExecuteTime - startTime, + System.currentTimeMillis() - startTime); } else { - messageLogger.info("pkg|eventMesh2c|cmd={}|pkg={}|user={}|wait={}ms|cost={}ms", pkg.getHeader().getCommand(), pkg, + messageLogger + .info("pkg|eventMesh2c|cmd={}|pkg={}|user={}|wait={}ms|cost={}ms", pkg.getHeader().getCmd(), pkg, user, taskExecuteTime - startTime, System.currentTimeMillis() - startTime); } } -// public static org.apache.rocketmq.common.message.Message decodeMessage(AccessMessage accessMessage) { -// org.apache.rocketmq.common.message.Message msg = new org.apache.rocketmq.common.message.Message(); -// msg.setTopic(accessMessage.getTopic()); -// msg.setBody(accessMessage.getBody().getBytes()); -// msg.getProperty("init"); -// for (Map.Entry property : accessMessage.getProperties().entrySet()) { -// msg.getProperties().put(property.getKey(), property.getValue()); -// } -// return msg; -// } - -// public static AccessMessage encodeMessage(org.apache.rocketmq.common.message.Message msg) throws Exception { -// AccessMessage accessMessage = new AccessMessage(); -// accessMessage.setBody(new String(msg.getBody(), "UTF-8")); -// accessMessage.setTopic(msg.getTopic()); -// for (Map.Entry property : msg.getProperties().entrySet()) { -// accessMessage.getProperties().put(property.getKey(), property.getValue()); -// } -// return accessMessage; -// } - -// public static org.apache.rocketmq.common.message.Message messageMapper(org.apache.rocketmq.common.message.Message -// message) { -// org.apache.rocketmq.common.message.Message msg = new org.apache.rocketmq.common.message.Message(); -// msg.setTopic(message.getTopic()); -// msg.setBody(message.getBody()); -// msg.getProperty("init"); -// for (Map.Entry property : message.getProperties().entrySet()) { -// msg.getProperties().put(property.getKey(), property.getValue()); -// } -// return msg; -// } - /** * print part of the mq message * @@ -161,7 +140,8 @@ public static String printMqMessage(EventMeshMessage eventMeshMessage) { } String result = String.format("Message [topic=%s,TTL=%s,uniqueId=%s,bizSeq=%s]", eventMeshMessage - .getTopic(), properties.get(EventMeshConstants.TTL), properties.get(EventMeshConstants.RR_REQUEST_UNIQ_ID), bizSeqNo); + .getTopic(), properties.get(EventMeshConstants.TTL), properties.get(EventMeshConstants.RR_REQUEST_UNIQ_ID), + bizSeqNo); return result; } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/ValueComparator.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/ValueComparator.java index 2eb24e57fd..510db76109 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/ValueComparator.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/ValueComparator.java @@ -23,6 +23,10 @@ public class ValueComparator implements Comparator> { @Override public int compare(Map.Entry x, Map.Entry y) { - return x.getValue().intValue() - y.getValue().intValue(); + if(x.getValue().intValue() != y.getValue().intValue()){ + return x.getValue().intValue() - y.getValue().intValue(); + }else { + return x.getKey().compareTo(y.getKey()); + } } } diff --git a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/MessageUtils.java b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/MessageUtils.java index d8d01f7f0c..0f20828bcb 100644 --- a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/MessageUtils.java +++ b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/MessageUtils.java @@ -188,7 +188,7 @@ public static Subscription generateSubscription(String topic, SubscriptionMode s public static EventMeshMessage generateRRMsg(String topic, int i) { EventMeshMessage msg = new EventMeshMessage(); msg.setTopic(topic); - msg.getProperties().put("msgType", "persistent"); + msg.getProperties().put("msgtype", "persistent"); msg.getProperties().put("TTL", "300000"); msg.getProperties().put("KEYS", generateRandomString(16)); msg.setBody("testRR" + i); diff --git a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/Server.java b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/Server.java index 4a43511fbe..d52eecc830 100644 --- a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/Server.java +++ b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/Server.java @@ -34,7 +34,7 @@ public class Server { public void startAccessServer() throws Exception { EventMeshHTTPConfiguration eventMeshHttpConfiguration = new EventMeshHTTPConfiguration(null); eventMeshHttpConfiguration.init(); - server = new EventMeshServer(eventMeshHttpConfiguration, null); + server = new EventMeshServer(eventMeshHttpConfiguration, null, null); server.init(); server.start(); } diff --git a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/AsyncPubClient.java b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/AsyncPubClient.java index 5fdea19614..14ee1ddbc7 100644 --- a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/AsyncPubClient.java +++ b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/AsyncPubClient.java @@ -19,7 +19,7 @@ import io.netty.channel.ChannelHandlerContext; -import org.apache.eventmesh.common.ThreadUtil; +import org.apache.eventmesh.common.utils.ThreadUtils; import org.apache.eventmesh.common.protocol.tcp.Package; import org.apache.eventmesh.runtime.client.common.ClientConstants; @@ -46,7 +46,7 @@ public void handle(Package msg, ChannelHandlerContext ctx) { }); for (int i = 0; i < 1; i++) { - ThreadUtil.randomSleep(0, 500); + ThreadUtils.randomSleep(0, 500); pubClient.broadcast(MessageUtils.asyncMessage(ClientConstants.ASYNC_TOPIC, i), 5000); } } diff --git a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/BroadCastPubClient.java b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/BroadCastPubClient.java index 5594e900a7..d85e8c364f 100644 --- a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/BroadCastPubClient.java +++ b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/BroadCastPubClient.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.runtime.demo; -import org.apache.eventmesh.common.ThreadUtil; +import org.apache.eventmesh.common.utils.ThreadUtils; import org.apache.eventmesh.runtime.client.common.ClientConstants; import org.apache.eventmesh.runtime.client.common.MessageUtils; @@ -30,7 +30,7 @@ public static void main(String[] args) throws Exception { pubClient.init(); pubClient.heartbeat(); for (int i = 0; i < 10000; i++) { - ThreadUtil.randomSleep(0, 500); + ThreadUtils.randomSleep(0, 500); pubClient.broadcast(MessageUtils.broadcastMessage(ClientConstants.BROADCAST_TOPIC, i), 5000); } } diff --git a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/CClientDemo.java b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/CClientDemo.java index 4f33595ee0..cad2c5018b 100644 --- a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/CClientDemo.java +++ b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/CClientDemo.java @@ -63,7 +63,7 @@ public static void main(String[] args) throws Exception { client.registerSubBusiHandler(new ReceiveMsgHook() { @Override public void handle(Package msg, ChannelHandlerContext ctx) { - if (msg.getHeader().getCommand() == Command.ASYNC_MESSAGE_TO_CLIENT || msg.getHeader().getCommand() == Command.BROADCAST_MESSAGE_TO_CLIENT) { + if (msg.getHeader().getCmd() == Command.ASYNC_MESSAGE_TO_CLIENT || msg.getHeader().getCmd() == Command.BROADCAST_MESSAGE_TO_CLIENT) { logger.error("receive message-------------------------------------" + msg.toString()); } } diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/build.gradle b/eventmesh-schema-registry/eventmesh-schema-registry-server/build.gradle deleted file mode 100644 index 4d9674b475..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/build.gradle +++ /dev/null @@ -1,31 +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. - */ - -dependencies { - implementation 'org.springframework.boot:spring-boot-starter-data-jdbc:2.5.5' - implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.5.5' - implementation 'org.springframework.boot:spring-boot-starter-jdbc:2.5.5' - implementation 'org.springframework.boot:spring-boot-starter-web:2.5.5' - implementation 'org.springframework:spring-beans:5.3.10' - compileOnly 'org.projectlombok:lombok:1.18.22' - runtimeOnly 'com.h2database:h2:1.4.200' - annotationProcessor 'org.projectlombok:lombok:1.18.22' -} - -test { - useJUnitPlatform() -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/controller/CompatibilityController.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/controller/CompatibilityController.java deleted file mode 100644 index dc927eac1c..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/controller/CompatibilityController.java +++ /dev/null @@ -1,54 +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 org.apache.eventmesh.schema.registry.server.controller; - -import org.apache.eventmesh.schema.registry.server.domain.Compatibility; -import org.apache.eventmesh.schema.registry.server.domain.Schema; -import org.apache.eventmesh.schema.registry.server.response.CompatibilityResultResponse; -import org.apache.eventmesh.schema.registry.server.service.CompatibilityService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -@RestController -@RequestMapping("/compatibility") -public class CompatibilityController { - - @Autowired - CompatibilityService compatibilityService; - - @PostMapping("/subjects/{subject}/versions/{version}") - public ResponseEntity checkWhetherCompatible(@PathVariable("subject") String subject, - @PathVariable("version") Integer version, - @RequestBody Schema schema){ - CompatibilityResultResponse resultResponse = compatibilityService.checkWhetherCompatible(subject, version, schema); - return ResponseEntity.ok(resultResponse); - } - - @GetMapping("/{subject}") - public ResponseEntity getCompatibilityBySubject(@PathVariable("subject") String subject){ - Compatibility compatibility = compatibilityService.getCompatibilityBySubject(subject); - return ResponseEntity.ok(compatibility); - } - - @PutMapping("/{subject}") - public ResponseEntity updateCompatibilityBySubject(@PathVariable("subject") String subject, - @RequestBody Compatibility compatibility){ - Compatibility updatedCompatibility = compatibilityService.updateCompatibilityBySubject(subject, compatibility); - return ResponseEntity.ok(updatedCompatibility); - } -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/controller/SchemaController.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/controller/SchemaController.java deleted file mode 100644 index 31fafa7ef5..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/controller/SchemaController.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 org.apache.eventmesh.schema.registry.server.controller; - -import org.apache.eventmesh.schema.registry.server.domain.Schema; -import org.apache.eventmesh.schema.registry.server.response.SubjectAndVersionResponse; -import org.apache.eventmesh.schema.registry.server.service.SchemaService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -@RestController -@RequestMapping("/schemas") -public class SchemaController { - @Autowired - SchemaService schemaService; - - @GetMapping("/ids/{id}") - public ResponseEntity fetchSchemaById(@PathVariable("id") long id){ - Schema schema = schemaService.getSchemaById(id); - return ResponseEntity.ok(schema); - } - - @GetMapping("/ids/{id}/subjects") - public ResponseEntity fetchSubjectAndVersionById(@PathVariable("id") long id){ - SubjectAndVersionResponse subjectAndVersionResponse = schemaService.getSubjectAndVersionById(id); - return ResponseEntity.ok(subjectAndVersionResponse); - } -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/controller/SubjectController.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/controller/SubjectController.java deleted file mode 100644 index 6edeabd827..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/controller/SubjectController.java +++ /dev/null @@ -1,85 +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 org.apache.eventmesh.schema.registry.server.controller; - -import org.apache.eventmesh.schema.registry.server.domain.Schema; -import org.apache.eventmesh.schema.registry.server.domain.Subject; -import org.apache.eventmesh.schema.registry.server.domain.SubjectWithSchema; -import org.apache.eventmesh.schema.registry.server.response.SchemaIdResponse; -import org.apache.eventmesh.schema.registry.server.service.SubjectService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -@RestController -@RequestMapping("/subjects") -public class SubjectController { - - @Autowired - SubjectService subjectService; - - @GetMapping({"","/"}) - public ResponseEntity> getAllSubjects(){ - List subjects = subjectService.getAllSubjects(); - return ResponseEntity.ok(subjects); - } - - @GetMapping("/{subject}/versions") - public ResponseEntity> getAllVersionBySubject(@PathVariable("subject") String subject){ - List versions = subjectService.getAllVersionsBySubject(subject); - return ResponseEntity.ok(versions); - } - - @DeleteMapping("/subjects/{subject}") - public ResponseEntity> deleteSubjectAndAllSchemaBySubject(@PathVariable("subject") String subject){ - List versions = subjectService.deleteSubjectAndAllSchemaBySubject(subject); - return ResponseEntity.ok(versions); - } - - @GetMapping("/{subject}") - public ResponseEntity getSubjectByName(@PathVariable("subject") String subject){ - Subject getSubject = subjectService.getSubjectByName(subject); - return ResponseEntity.ok(getSubject); - } - - @GetMapping("/{subject}/versions/{version}/schema") - public ResponseEntity getSchemaBySubjectAndVersion(@PathVariable("subject")String subject, @PathVariable("version")int version){ - SubjectWithSchema subjectWithSchema = subjectService.getSchemaBySubjectAndVersion(subject, version); - return ResponseEntity.ok(subjectWithSchema); - } - - @PostMapping("/subjects/{subject}/versions") - public ResponseEntity checkOrRegisterSchema(@PathVariable("subject") String subject, @RequestBody Schema schema){ - SchemaIdResponse schemaIdResponse = subjectService.checkOrRegisterSchema(subject, schema); - return ResponseEntity.ok(schemaIdResponse); - } - - @PostMapping("/subjects/{subject}") - public ResponseEntity updateSubjectIfDifferent(@PathVariable("subject") String subjectName, @RequestBody Subject subject){ - Subject updatedSubject = subjectService.updateSubjectIfDifferent(subjectName, subject); - return ResponseEntity.ok(updatedSubject); - } - - @DeleteMapping("/subjects/{subject}/versions/{version}") - public ResponseEntity deleteSchemaBySubjectAndVersion(@PathVariable("subject")String subject, @PathVariable("version") int version){ - Integer deletedId = subjectService.deleteSchemaBySubjectAndVersion(subject, version); - return ResponseEntity.ok(deletedId); - } -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/SchemaWithSubjectName.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/SchemaWithSubjectName.java deleted file mode 100644 index 0cc9c94310..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/SchemaWithSubjectName.java +++ /dev/null @@ -1,59 +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 org.apache.eventmesh.schema.registry.server.domain; - -import lombok.*; - -import javax.persistence.*; - -@Entity -@Setter -@Getter -@AllArgsConstructor -@NoArgsConstructor -@Builder -@Table(name = "SCHEMA") -public class SchemaWithSubjectName { - @Id - @Column(name = "ID") - @GeneratedValue(strategy = GenerationType.IDENTITY) - private long id; - - @Column(name = "NAME") - private String name; - - @Column(name = "COMMENT") - private String comment; - - @Column(name = "SERIALIZATION") - private String serialization; - - @Column(name = "SCHEMATYPE") - private String schemaType; - - @Column(name = "SCHEMADEFINITION", length = 10240) - private String schemaDefinition; - - @Column(name = "VALIDATOR") - private String validator; - - @Column(name = "VERSION") - private int version; - - @Column(name = "SUBJECT") - private String subject; -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Subject.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Subject.java deleted file mode 100644 index 9634916a55..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Subject.java +++ /dev/null @@ -1,60 +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 org.apache.eventmesh.schema.registry.server.domain; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.annotations.DynamicUpdate; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Data -@DynamicUpdate -@AllArgsConstructor -@NoArgsConstructor -@Table(name = "SUBJECT") -public class Subject { - @Id - @Column(name = "SUBJECT") - private String subject; - - @Column(name = "TENANT") - private String tenant; - - @Column(name = "NAMESPACE") - private String namespace; - - @Column(name = "APP") - private String app; - - @Column(name = "DESCRIPTION") - private String description; - - @Column(name = "STATUS") - private String status; - - @Column(name = "COMPATIBILITY") - private String compatibility; - - @Column(name = "COORDINATE") - private String coordinate; -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/SubjectWithSchema.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/SubjectWithSchema.java deleted file mode 100644 index 1a8dc3d431..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/SubjectWithSchema.java +++ /dev/null @@ -1,57 +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 org.apache.eventmesh.schema.registry.server.domain; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class SubjectWithSchema { - - public SubjectWithSchema(Subject subject, Schema schema){ - this.subject = subject.getSubject(); - this.tenant = subject.getTenant(); - this.namespace = subject.getNamespace(); - this.app = subject.getApp(); - this.description = subject.getDescription(); - this.status = subject.getStatus(); - this.compatibility = subject.getCompatibility(); - this.coordinate = subject.getCoordinate(); - this.schema = schema; - } - - private String subject; - - private String tenant; - - private String namespace; - - private String app; - - private String description; - - private String status; - - private String compatibility; - - private String coordinate; - - private Schema schema; -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/enumerate/CompatibilityEnum.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/enumerate/CompatibilityEnum.java deleted file mode 100644 index dfa2103e36..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/enumerate/CompatibilityEnum.java +++ /dev/null @@ -1,33 +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 org.apache.eventmesh.schema.registry.server.enumerate; - -import lombok.AllArgsConstructor; - -@AllArgsConstructor -public enum CompatibilityEnum { - BACKWARD("BACKWARD", "Consumers using the new schema can read data produced with the last schema."), - BACKWARD_TRANSITIVE("BACKWARD_TRANSITIVE", "Consumers using the new schema can read data sent by the producer using all previously registered schemas."), - FORWARD("FORWARD", "Data produced with a new schema can be read by consumers using the last schema."), - FORWARD_TRANSITIVE("FORWARD_TRANSITIVE", "Data produced with a new schema can be read by consumers using all registered schemas."), - FULL("FULL", "The new schema is backward and forward compatible with the newly registered schema."), - FULL_TRANSITIVE("FULL_TRANSITIVE", "The newly registered schema is backward and forward compatible with all previously registered schemas."), - NONE("NONE", "Schema compatibility checks are disabled."); - - private String name; - private String description; -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/ErrorResponse.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/ErrorResponse.java deleted file mode 100644 index 94ad33f168..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/ErrorResponse.java +++ /dev/null @@ -1,29 +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 org.apache.eventmesh.schema.registry.server.exception; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; - -@Getter -@Setter -@AllArgsConstructor -public class ErrorResponse { - private String err_code; - private String err_message; -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/ExceptionEnum.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/ExceptionEnum.java deleted file mode 100644 index a54b915828..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/ExceptionEnum.java +++ /dev/null @@ -1,42 +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 org.apache.eventmesh.schema.registry.server.exception; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.springframework.http.HttpStatus; - -@Getter -@AllArgsConstructor -public enum ExceptionEnum { - - UnAuthorizedException(HttpStatus.UNAUTHORIZED, "40101", "Unauthorized Exception"), - SchemaNonExist(HttpStatus.NOT_FOUND,"40401", "Schema Non-exist Exception"), - SubjectNonExist(HttpStatus.NOT_FOUND, "40402", "Subject Non-exist Exception"), - VersionNonExist(HttpStatus.NOT_FOUND, "40403", "Version Non-exist Exception"), - CompatibilityException(HttpStatus.CONFLICT, "40901", "Compatibility Exception"), - SchemaFormatException(HttpStatus.UNPROCESSABLE_ENTITY, "42201", "Schema Format Exception"), - SubjectFormatException(HttpStatus.UNPROCESSABLE_ENTITY, "42202", "Subject Format Exception"), - VersionFormatException(HttpStatus.UNPROCESSABLE_ENTITY, "42203", "Version Format Exception"), - CompatibilityFormatException(HttpStatus.UNPROCESSABLE_ENTITY, "42204", "Compatibility Format Exception"), - StorageServiceException(HttpStatus.INTERNAL_SERVER_ERROR, "50001", "Storage Service Exception"), - TimeoutException(HttpStatus.INTERNAL_SERVER_ERROR, "50002", "Timeout Exception"); - - private HttpStatus status; - private String exceptionCode; - private String description; -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/OpenSchemaException.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/OpenSchemaException.java deleted file mode 100644 index 8d24dce4a7..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/OpenSchemaException.java +++ /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. - */ -package org.apache.eventmesh.schema.registry.server.exception; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import org.springframework.http.HttpStatus; - -@Getter -@Setter -@AllArgsConstructor -public class OpenSchemaException extends RuntimeException{ - protected HttpStatus err_status; - protected String err_code; - protected String err_message; - - public OpenSchemaException(ExceptionEnum e){ - this.err_status = e.getStatus(); - this.err_code = e.getExceptionCode(); - this.err_message = e.getDescription(); - } -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/repository/SchemaRepository.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/repository/SchemaRepository.java deleted file mode 100644 index f461f049da..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/repository/SchemaRepository.java +++ /dev/null @@ -1,42 +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 org.apache.eventmesh.schema.registry.server.repository; - -import org.apache.eventmesh.schema.registry.server.domain.Schema; -import org.apache.eventmesh.schema.registry.server.domain.SchemaWithSubjectName; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface SchemaRepository extends JpaRepository { - - SchemaWithSubjectName getSchemaById(long id); - - @Query(value = "select VERSION from SCHEMA", nativeQuery = true) - List getVersionsBySubject(String subject); - - List deleteSchemasBySubject(String subject); - - Integer deleteSchemaBySubjectAndVersion(String subject, int version); - - Schema getSchemaBySubjectAndVersion(String subject, int version); - - List getSchemaWithSubjectNamesBySubjectOrderByVersionDesc(String subject); -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/repository/SubjectRepository.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/repository/SubjectRepository.java deleted file mode 100644 index 92461489a8..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/repository/SubjectRepository.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 org.apache.eventmesh.schema.registry.server.repository; - -import org.apache.eventmesh.schema.registry.server.domain.Subject; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface SubjectRepository extends JpaRepository { - - @Query(value = "select SUBJECT from SUBJECT", nativeQuery = true) - List getAllSubject(); - - @Query(value = "select VERSION from SCHEMA v where v.SUBJECT=:subject",nativeQuery = true) - List getAllVersionsBySubject(@Param("subject") String subject); - - Subject deleteSubjectBySubject(String subject); - - Subject getSubjectBySubject(String subject); -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/response/CompatibilityResultResponse.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/response/CompatibilityResultResponse.java deleted file mode 100644 index a1862d17b5..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/response/CompatibilityResultResponse.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 org.apache.eventmesh.schema.registry.server.response; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class CompatibilityResultResponse { - boolean is_compatibility; -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/response/SchemaIdResponse.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/response/SchemaIdResponse.java deleted file mode 100644 index a7e1b3e4b7..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/response/SchemaIdResponse.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 org.apache.eventmesh.schema.registry.server.response; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class SchemaIdResponse { - String id; -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/service/CompatibilityService.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/service/CompatibilityService.java deleted file mode 100644 index 3b15638f58..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/service/CompatibilityService.java +++ /dev/null @@ -1,101 +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 org.apache.eventmesh.schema.registry.server.service; - -import org.apache.eventmesh.schema.registry.server.domain.Compatibility; -import org.apache.eventmesh.schema.registry.server.domain.Schema; -import org.apache.eventmesh.schema.registry.server.domain.Subject; -import org.apache.eventmesh.schema.registry.server.exception.ExceptionEnum; -import org.apache.eventmesh.schema.registry.server.exception.OpenSchemaException; -import org.apache.eventmesh.schema.registry.server.repository.SchemaRepository; -import org.apache.eventmesh.schema.registry.server.repository.SubjectRepository; -import org.apache.eventmesh.schema.registry.server.response.CompatibilityResultResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class CompatibilityService { - - @Autowired - SubjectRepository subjectRepository; - - @Autowired - SchemaRepository schemaRepository; - - - public CompatibilityResultResponse checkWhetherCompatible(String subject, Integer version, Schema schema){ - Subject getSubject = null; - Schema getSchema = null; - CompatibilityResultResponse response = null; - try { - getSubject = subjectRepository.getSubjectBySubject(subject); - }catch (Exception e){ - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - if(getSubject == null){ - throw new OpenSchemaException(ExceptionEnum.SubjectNonExist); - } - - try { - getSchema = schemaRepository.getSchemaBySubjectAndVersion(subject, version); - }catch (Exception e){ - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - if(getSchema == null){ - throw new OpenSchemaException(ExceptionEnum.SchemaNonExist); - } - // todo check the compatibility - - return response; - } - - - public Compatibility getCompatibilityBySubject(String subject){ - Subject getSubject = null; - try { - getSubject = subjectRepository.getSubjectBySubject(subject); - }catch (Exception e){ - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - - if(getSubject==null){ - throw new OpenSchemaException(ExceptionEnum.SubjectNonExist); - } - - return new Compatibility(getSubject.getCompatibility()); - } - - public Compatibility updateCompatibilityBySubject(String subject, Compatibility compatibility){ - Subject getSubject = null; - try { - getSubject = subjectRepository.getSubjectBySubject(subject); - }catch (Exception e){ - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - if(getSubject == null){ - throw new OpenSchemaException(ExceptionEnum.SubjectNonExist); - } - getSubject.setCompatibility(compatibility.getCompatibility()); - try { - // todo check the compatibility among schemas of newly set compatibility - subjectRepository.save(getSubject); - }catch (Exception e){ - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - return compatibility; - } -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/service/SchemaService.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/service/SchemaService.java deleted file mode 100644 index 11ef1ee903..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/service/SchemaService.java +++ /dev/null @@ -1,68 +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 org.apache.eventmesh.schema.registry.server.service; - -import org.apache.eventmesh.schema.registry.server.domain.Schema; -import org.apache.eventmesh.schema.registry.server.domain.SchemaWithSubjectName; -import org.apache.eventmesh.schema.registry.server.exception.ExceptionEnum; -import org.apache.eventmesh.schema.registry.server.exception.OpenSchemaException; -import org.apache.eventmesh.schema.registry.server.repository.SchemaRepository; -import org.apache.eventmesh.schema.registry.server.response.SubjectAndVersionResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class SchemaService { - - @Autowired - SchemaRepository schemaRepository; - - public Schema getSchemaById(long id){ - SchemaWithSubjectName schemaWithSubjectName = null; - try { - schemaWithSubjectName = schemaRepository.getSchemaById(id); - }catch (Exception e){ - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - if(schemaWithSubjectName==null){ - throw new OpenSchemaException(ExceptionEnum.SchemaNonExist); - } - Schema schema = new Schema(); - schema.setId(String.valueOf(schemaWithSubjectName.getId())); - schema.setName(schemaWithSubjectName.getName()); - schema.setComment(schemaWithSubjectName.getComment()); - schema.setSerialization(schemaWithSubjectName.getSerialization()); - schema.setSchemaType(schemaWithSubjectName.getSchemaType()); - schema.setSchemaDefinition(schemaWithSubjectName.getSchemaDefinition()); - schema.setValidator(schemaWithSubjectName.getValidator()); - schema.setVersion(schemaWithSubjectName.getVersion()); - return schema; - } - - public SubjectAndVersionResponse getSubjectAndVersionById(long id){ - SchemaWithSubjectName schemaWithSubjectName = null; - try { - schemaWithSubjectName = schemaRepository.getSchemaById(id); - }catch (Exception e){ - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - if(schemaWithSubjectName==null){ - throw new OpenSchemaException(ExceptionEnum.SchemaNonExist); - } - return new SubjectAndVersionResponse(schemaWithSubjectName.getSubject(), schemaWithSubjectName.getVersion()); - } -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/service/SubjectService.java b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/service/SubjectService.java deleted file mode 100644 index 228f5957cd..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/service/SubjectService.java +++ /dev/null @@ -1,221 +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 org.apache.eventmesh.schema.registry.server.service; - -import org.apache.eventmesh.schema.registry.server.domain.*; -import org.apache.eventmesh.schema.registry.server.exception.ExceptionEnum; -import org.apache.eventmesh.schema.registry.server.exception.OpenSchemaException; -import org.apache.eventmesh.schema.registry.server.repository.SchemaRepository; -import org.apache.eventmesh.schema.registry.server.repository.SubjectRepository; -import org.apache.eventmesh.schema.registry.server.response.SchemaIdResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Service -public class SubjectService { - - @Autowired - SubjectRepository subjectRepository; - - @Autowired - SchemaRepository schemaRepository; - - public List getAllSubjects() { - List subjects; - try { - subjects = subjectRepository.getAllSubject(); - } catch (Exception e) { - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - return subjects; - } - - public List getAllVersionsBySubject(String subject) { - List versions; - try { - versions = subjectRepository.getAllVersionsBySubject(subject); - } catch (Exception e) { - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - if (versions == null) { - throw new OpenSchemaException(ExceptionEnum.SubjectNonExist); - } - return versions; - } - - public List deleteSubjectAndAllSchemaBySubject(String subject) { - List versions; - Subject deletedSubject; - try { - deletedSubject = subjectRepository.deleteSubjectBySubject(subject); - } catch (Exception e) { - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - if (deletedSubject == null) { - throw new OpenSchemaException(ExceptionEnum.SubjectNonExist); - } - - try { - versions = schemaRepository.deleteSchemasBySubject(subject); - } catch (Exception e) { - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - return versions; - } - - public Subject getSubjectByName(String subject) { - Subject getSubject; - try { - getSubject = subjectRepository.getSubjectBySubject(subject); - } catch (Exception e) { - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - - if (getSubject == null) { - throw new OpenSchemaException(ExceptionEnum.SubjectNonExist); - } - - return getSubject; - } - - public SubjectWithSchema getSchemaBySubjectAndVersion(String subject, int version) { - Schema schema = null; - Subject getSubject = null; - try { - getSubject = subjectRepository.getSubjectBySubject(subject); - schema = schemaRepository.getSchemaBySubjectAndVersion(subject, version); - } catch (Exception e) { - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - - if (getSubject == null) { - throw new OpenSchemaException(ExceptionEnum.VersionNonExist); - } - - if (schema == null) { - throw new OpenSchemaException(ExceptionEnum.SubjectNonExist); - } - - return new SubjectWithSchema(getSubject, schema); - } - - - public SchemaIdResponse checkOrRegisterSchema(String subject, Schema schema) { - Subject subjectBySubject = null; - try { - subjectBySubject = subjectRepository.getSubjectBySubject(subject); - } catch (Exception e) { - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - - if (subjectBySubject == null) { - throw new OpenSchemaException(ExceptionEnum.SubjectNonExist); - } - - List schemaWithNames = null; - try { - schemaWithNames = schemaRepository.getSchemaWithSubjectNamesBySubjectOrderByVersionDesc(subject); - } catch (Exception e) { - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - - SchemaIdResponse schemaIdResponse = schemaWithNames - .stream() - .filter(schemaWithSubjectName - -> schema.getSerialization().equals(schemaWithSubjectName.getSerialization()) - && schema.getSchemaType().equals(schemaWithSubjectName.getSchemaType()) - && schema.getSchemaDefinition().equals(schemaWithSubjectName.getSchemaType())) - .findFirst() - .map(schemaWithSubjectName - -> new SchemaIdResponse(String.valueOf(schemaWithSubjectName.getId()))) - .orElse(null); - - if (schemaIdResponse == null) { - SchemaWithSubjectName schemaWithSubjectName = SchemaWithSubjectName - .builder() - .name(schema.getName()) - .comment(schema.getComment()) - .serialization(schema.getSerialization()) - .schemaType(schema.getSchemaType()) - .schemaDefinition(schema.getSchemaDefinition()) - .validator(schema.getValidator()) - .version(schemaWithNames.get(0).getVersion() + 1) - .subject(subject) - .build(); - try { - SchemaWithSubjectName save = schemaRepository.save(schemaWithSubjectName); - schemaIdResponse = new SchemaIdResponse(String.valueOf(save.getId())); - } catch (Exception e) { - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - - } - return schemaIdResponse; - } - - public Subject updateSubjectIfDifferent(String subjectName, Subject subject) { - Subject getSubject = null; - Subject returnSubject = null; - try { - getSubject = subjectRepository.getSubjectBySubject(subjectName); - } catch (Exception e) { - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - if (getSubject == null) { - returnSubject = subjectRepository.save(subject); - } else { - if (getSubject.equals(subject)) { - returnSubject = subject; - } else { - //todo - // if compatibility is changed, the left schemas should satisfy compatibility - } - } - return returnSubject; - } - - public Integer deleteSchemaBySubjectAndVersion(String subject, int version) { - Integer deletedVersion = null; - // todo complete the logic here for compatibility check - try { - deletedVersion = schemaRepository.deleteSchemaBySubjectAndVersion(subject, version); - } catch (Exception e) { - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - if (deletedVersion == null) { - throw new OpenSchemaException(ExceptionEnum.SchemaNonExist); - } - return deletedVersion; - } - - public Compatibility getCompatibilityBySubject(String subject) { - Subject getSubject = null; - try { - getSubject = subjectRepository.getSubjectBySubject(subject); - } catch (Exception e) { - throw new OpenSchemaException(ExceptionEnum.StorageServiceException); - } - - if (getSubject == null) { - throw new OpenSchemaException(ExceptionEnum.SubjectNonExist); - } - - return new Compatibility(getSubject.getCompatibility()); - } -} diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/resources/application.yml b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/resources/application.yml deleted file mode 100644 index 69cb7870f5..0000000000 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/resources/application.yml +++ /dev/null @@ -1,35 +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. -# - -spring: - h2: - console: - path: /h2-console - enabled: true - datasource: - driver-class-name: org.h2.Driver - url: jdbc:h2:./eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/resources/h2/db - username: root - password: test - jpa: - database: h2 - hibernate: - ddl-auto: update - show-sql: true - -server: - port: 13579 diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/resources/h2/db.mv.db b/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/resources/h2/db.mv.db deleted file mode 100644 index 7a7a4006f2..0000000000 Binary files a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/resources/h2/db.mv.db and /dev/null differ diff --git a/eventmesh-sdk-java/build.gradle b/eventmesh-sdk-java/build.gradle index 298e250811..d926f2b058 100644 --- a/eventmesh-sdk-java/build.gradle +++ b/eventmesh-sdk-java/build.gradle @@ -15,6 +15,8 @@ * limitations under the License. */ +def grpcVersion = '1.15.0' + dependencies { implementation project(":eventmesh-common") implementation project(":eventmesh-common") @@ -22,11 +24,21 @@ dependencies { implementation "com.fasterxml.jackson.core:jackson-databind" implementation "com.fasterxml.jackson.core:jackson-core" implementation "com.fasterxml.jackson.core:jackson-annotations" + implementation "org.apache.commons:commons-collections4" implementation "io.netty:netty-all" implementation "org.apache.httpcomponents:httpclient" - testImplementation project(":eventmesh-common") + implementation "io.grpc:grpc-protobuf:${grpcVersion}" + implementation "io.grpc:grpc-stub:${grpcVersion}" + implementation "io.grpc:grpc-netty:${grpcVersion}" + implementation "io.grpc:grpc-netty-shaded:${grpcVersion}" + + // protocol + implementation "io.cloudevents:cloudevents-core" + implementation "io.cloudevents:cloudevents-json-jackson" + implementation "io.openmessaging:openmessaging-api" + testImplementation project(":eventmesh-common") testImplementation "com.fasterxml.jackson.core:jackson-databind" @@ -36,6 +48,12 @@ dependencies { testImplementation "io.netty:netty-all" testImplementation "org.apache.httpcomponents:httpclient" + compileOnly 'org.projectlombok:lombok:1.18.22' + annotationProcessor 'org.projectlombok:lombok:1.18.22' + + testCompileOnly 'org.projectlombok:lombok:1.18.22' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' + implementation "io.grpc:grpc-protobuf:1.15.0" implementation "io.grpc:grpc-stub:1.15.0" implementation "com.google.protobuf:protobuf-java-util:3.5.1" diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java new file mode 100644 index 0000000000..5f1083d5e4 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java @@ -0,0 +1,47 @@ +package org.apache.eventmesh.client.grpc; + +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.client.grpc.util.EventMeshClientUtil; +import org.apache.eventmesh.common.protocol.grpc.protos.ConsumerServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EventMeshGrpcConsumer implements AutoCloseable { + + private static Logger logger = LoggerFactory.getLogger(EventMeshGrpcConsumer.class); + + private EventMeshGrpcClientConfig clientConfig; + + private ManagedChannel channel; + + public EventMeshGrpcConsumer(EventMeshGrpcClientConfig clientConfig) { + this.clientConfig = clientConfig; + } + + public void init() { + channel = ManagedChannelBuilder.forAddress(clientConfig.getServerAddr(), clientConfig.getServerPort()) + .usePlaintext().build(); + } + + public Response subscribe(Subscription subscription) { + logger.info("Subscribe topic " + subscription.toString()); + ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); + + Subscription enhancedSubscription = Subscription.newBuilder(subscription) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setConsumerGroup(clientConfig.getConsumerGroup()) + .build(); + Response response = consumerClient.subscribe(enhancedSubscription); + logger.info("Received response " + response.toString()); + return response; + } + + @Override + public void close() throws Exception { + channel.shutdown(); + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java new file mode 100644 index 0000000000..01203c84bb --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java @@ -0,0 +1,48 @@ +package org.apache.eventmesh.client.grpc; + +import io.cloudevents.SpecVersion; +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.client.grpc.util.EventMeshClientUtil; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EventMeshGrpcProducer implements AutoCloseable { + + private static Logger logger = LoggerFactory.getLogger(EventMeshGrpcProducer.class); + + private EventMeshGrpcClientConfig clientConfig; + + private ManagedChannel channel; + + public EventMeshGrpcProducer(EventMeshGrpcClientConfig clientConfig) { + this.clientConfig = clientConfig; + } + + public void init() { + channel = ManagedChannelBuilder.forAddress(clientConfig.getServerAddr(), clientConfig.getServerPort()) + .usePlaintext().build(); + } + + public Response publish(EventMeshMessage message) { + logger.info("Publish message " + message.toString()); + PublisherServiceGrpc.PublisherServiceBlockingStub publisherClient = PublisherServiceGrpc.newBlockingStub(channel); + + EventMeshMessage enhancedMessage = EventMeshMessage.newBuilder(message) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setProducerGroup(clientConfig.getProducerGroup()) + .build(); + Response response = publisherClient.publish(enhancedMessage); + logger.info("Received response " + response.toString()); + return response; + } + + public void close() { + channel.shutdown(); + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java new file mode 100644 index 0000000000..cadbd830b8 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java @@ -0,0 +1,84 @@ +/* + * Licensed 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.eventmesh.client.grpc.config; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class EventMeshGrpcClientConfig { + + @Builder.Default + private String serverAddr = ""; + + @Builder.Default + private int serverPort = 10205; + + @Builder.Default + private String env = ""; + + @Builder.Default + private String consumerGroup = "DefaultConsumerGroup"; + + @Builder.Default + private String producerGroup = "DefaultProducerGroup"; + + @Builder.Default + private String idc = ""; + + @Builder.Default + private String ip = "127.0.0.1"; + + @Builder.Default + private String pid ="0"; + + @Builder.Default + private String sys = "sys123"; + + @Builder.Default + private String userName = ""; + + @Builder.Default + private String password = ""; + + @Builder.Default + private String language = "JAVA"; + + @Builder.Default + private boolean useTls = false; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("ClientConfig={") + .append("ServerAddr=").append(serverAddr).append(",") + .append("ServerPort=").append(serverPort).append(",") + .append("env=").append(env).append(",") + .append("idc=").append(idc).append(",") + .append("producerGroup=").append(producerGroup).append(",") + .append("consumerGroup=").append(consumerGroup).append(",") + .append("ip=").append(ip).append(",") + .append("pid=").append(pid).append(",") + .append("sys=").append(sys).append(",") + .append("userName=").append(userName).append(",") + .append("password=").append("***").append(",") + .append("useTls=").append(useTls).append("}"); + return sb.toString(); + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ConsumerServiceGrpc.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ConsumerServiceGrpc.java deleted file mode 100644 index aff9b4ce2c..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ConsumerServiceGrpc.java +++ /dev/null @@ -1,453 +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 org.apache.eventmesh.client.grpc.protos; - -import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; -import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.*; -import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; -import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.*; - -/** - * - */ -@javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.15.0)", - comments = "Source: eventmesh-client.proto") -public final class ConsumerServiceGrpc { - - private ConsumerServiceGrpc() { - } - - public static final String SERVICE_NAME = "eventmesh.client.ConsumerService"; - - // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getSubscribeMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "subscribe", - requestType = org.apache.eventmesh.client.grpc.protos.Subscription.class, - responseType = org.apache.eventmesh.client.grpc.protos.Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getSubscribeMethod() { - io.grpc.MethodDescriptor getSubscribeMethod; - if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { - synchronized (ConsumerServiceGrpc.class) { - if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { - ConsumerServiceGrpc.getSubscribeMethod = getSubscribeMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.ConsumerService", "subscribe")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Subscription.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) - .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribe")) - .build(); - } - } - } - return getSubscribeMethod; - } - - private static volatile io.grpc.MethodDescriptor getSubscribeStreamMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "subscribeStream", - requestType = org.apache.eventmesh.client.grpc.protos.Subscription.class, - responseType = org.apache.eventmesh.client.grpc.protos.Message.class, - methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - public static io.grpc.MethodDescriptor getSubscribeStreamMethod() { - io.grpc.MethodDescriptor getSubscribeStreamMethod; - if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { - synchronized (ConsumerServiceGrpc.class) { - if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { - ConsumerServiceGrpc.getSubscribeStreamMethod = getSubscribeStreamMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.ConsumerService", "subscribeStream")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Subscription.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Message.getDefaultInstance())) - .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribeStream")) - .build(); - } - } - } - return getSubscribeStreamMethod; - } - - private static volatile io.grpc.MethodDescriptor getUnsubscribeMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "unsubscribe", - requestType = org.apache.eventmesh.client.grpc.protos.Subscription.class, - responseType = org.apache.eventmesh.client.grpc.protos.Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getUnsubscribeMethod() { - io.grpc.MethodDescriptor getUnsubscribeMethod; - if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { - synchronized (ConsumerServiceGrpc.class) { - if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { - ConsumerServiceGrpc.getUnsubscribeMethod = getUnsubscribeMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.ConsumerService", "unsubscribe")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Subscription.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) - .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("unsubscribe")) - .build(); - } - } - } - return getUnsubscribeMethod; - } - - /** - * Creates a new async stub that supports all call types for the service - */ - public static ConsumerServiceStub newStub(io.grpc.Channel channel) { - return new ConsumerServiceStub(channel); - } - - /** - * Creates a new blocking-style stub that supports unary and streaming output calls on the service - */ - public static ConsumerServiceBlockingStub newBlockingStub( - io.grpc.Channel channel) { - return new ConsumerServiceBlockingStub(channel); - } - - /** - * Creates a new ListenableFuture-style stub that supports unary calls on the service - */ - public static ConsumerServiceFutureStub newFutureStub( - io.grpc.Channel channel) { - return new ConsumerServiceFutureStub(channel); - } - - /** - * - */ - public static abstract class ConsumerServiceImplBase implements io.grpc.BindableService { - - /** - * - */ - public void subscribe(org.apache.eventmesh.client.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getSubscribeMethod(), responseObserver); - } - - /** - * - */ - public void subscribeStream(org.apache.eventmesh.client.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getSubscribeStreamMethod(), responseObserver); - } - - /** - * - */ - public void unsubscribe(org.apache.eventmesh.client.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getUnsubscribeMethod(), responseObserver); - } - - @Override - public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getSubscribeMethod(), - asyncUnaryCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Subscription, - org.apache.eventmesh.client.grpc.protos.Response>( - this, METHODID_SUBSCRIBE))) - .addMethod( - getSubscribeStreamMethod(), - asyncServerStreamingCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Subscription, - org.apache.eventmesh.client.grpc.protos.Message>( - this, METHODID_SUBSCRIBE_STREAM))) - .addMethod( - getUnsubscribeMethod(), - asyncUnaryCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Subscription, - org.apache.eventmesh.client.grpc.protos.Response>( - this, METHODID_UNSUBSCRIBE))) - .build(); - } - } - - /** - * - */ - public static final class ConsumerServiceStub extends io.grpc.stub.AbstractStub { - private ConsumerServiceStub(io.grpc.Channel channel) { - super(channel); - } - - private ConsumerServiceStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected ConsumerServiceStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new ConsumerServiceStub(channel, callOptions); - } - - /** - * - */ - public void subscribe(org.apache.eventmesh.client.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getSubscribeMethod(), getCallOptions()), request, responseObserver); - } - - /** - * - */ - public void subscribeStream(org.apache.eventmesh.client.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncServerStreamingCall( - getChannel().newCall(getSubscribeStreamMethod(), getCallOptions()), request, responseObserver); - } - - /** - * - */ - public void unsubscribe(org.apache.eventmesh.client.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request, responseObserver); - } - } - - /** - * - */ - public static final class ConsumerServiceBlockingStub extends io.grpc.stub.AbstractStub { - private ConsumerServiceBlockingStub(io.grpc.Channel channel) { - super(channel); - } - - private ConsumerServiceBlockingStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected ConsumerServiceBlockingStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new ConsumerServiceBlockingStub(channel, callOptions); - } - - /** - * - */ - public org.apache.eventmesh.client.grpc.protos.Response subscribe(org.apache.eventmesh.client.grpc.protos.Subscription request) { - return blockingUnaryCall( - getChannel(), getSubscribeMethod(), getCallOptions(), request); - } - - /** - * - */ - public java.util.Iterator subscribeStream( - org.apache.eventmesh.client.grpc.protos.Subscription request) { - return blockingServerStreamingCall( - getChannel(), getSubscribeStreamMethod(), getCallOptions(), request); - } - - /** - * - */ - public org.apache.eventmesh.client.grpc.protos.Response unsubscribe(org.apache.eventmesh.client.grpc.protos.Subscription request) { - return blockingUnaryCall( - getChannel(), getUnsubscribeMethod(), getCallOptions(), request); - } - } - - /** - * - */ - public static final class ConsumerServiceFutureStub extends io.grpc.stub.AbstractStub { - private ConsumerServiceFutureStub(io.grpc.Channel channel) { - super(channel); - } - - private ConsumerServiceFutureStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected ConsumerServiceFutureStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new ConsumerServiceFutureStub(channel, callOptions); - } - - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture subscribe( - org.apache.eventmesh.client.grpc.protos.Subscription request) { - return futureUnaryCall( - getChannel().newCall(getSubscribeMethod(), getCallOptions()), request); - } - - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture unsubscribe( - org.apache.eventmesh.client.grpc.protos.Subscription request) { - return futureUnaryCall( - getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request); - } - } - - private static final int METHODID_SUBSCRIBE = 0; - private static final int METHODID_SUBSCRIBE_STREAM = 1; - private static final int METHODID_UNSUBSCRIBE = 2; - - private static final class MethodHandlers implements - io.grpc.stub.ServerCalls.UnaryMethod, - io.grpc.stub.ServerCalls.ServerStreamingMethod, - io.grpc.stub.ServerCalls.ClientStreamingMethod, - io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final ConsumerServiceImplBase serviceImpl; - private final int methodId; - - MethodHandlers(ConsumerServiceImplBase serviceImpl, int methodId) { - this.serviceImpl = serviceImpl; - this.methodId = methodId; - } - - @Override - @SuppressWarnings("unchecked") - public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - case METHODID_SUBSCRIBE: - serviceImpl.subscribe((org.apache.eventmesh.client.grpc.protos.Subscription) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_SUBSCRIBE_STREAM: - serviceImpl.subscribeStream((org.apache.eventmesh.client.grpc.protos.Subscription) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_UNSUBSCRIBE: - serviceImpl.unsubscribe((org.apache.eventmesh.client.grpc.protos.Subscription) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - default: - throw new AssertionError(); - } - } - - @Override - @SuppressWarnings("unchecked") - public io.grpc.stub.StreamObserver invoke( - io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - default: - throw new AssertionError(); - } - } - } - - private static abstract class ConsumerServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { - ConsumerServiceBaseDescriptorSupplier() { - } - - @Override - public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { - return org.apache.eventmesh.client.grpc.protos.EventmeshClient.getDescriptor(); - } - - @Override - public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { - return getFileDescriptor().findServiceByName("ConsumerService"); - } - } - - private static final class ConsumerServiceFileDescriptorSupplier - extends ConsumerServiceBaseDescriptorSupplier { - ConsumerServiceFileDescriptorSupplier() { - } - } - - private static final class ConsumerServiceMethodDescriptorSupplier - extends ConsumerServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { - private final String methodName; - - ConsumerServiceMethodDescriptorSupplier(String methodName) { - this.methodName = methodName; - } - - @Override - public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { - return getServiceDescriptor().findMethodByName(methodName); - } - } - - private static volatile io.grpc.ServiceDescriptor serviceDescriptor; - - public static io.grpc.ServiceDescriptor getServiceDescriptor() { - io.grpc.ServiceDescriptor result = serviceDescriptor; - if (result == null) { - synchronized (ConsumerServiceGrpc.class) { - result = serviceDescriptor; - if (result == null) { - serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) - .setSchemaDescriptor(new ConsumerServiceFileDescriptorSupplier()) - .addMethod(getSubscribeMethod()) - .addMethod(getSubscribeStreamMethod()) - .addMethod(getUnsubscribeMethod()) - .build(); - } - } - } - return result; - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/EventmeshClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/EventmeshClient.java deleted file mode 100644 index 9bd4db761d..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/EventmeshClient.java +++ /dev/null @@ -1,174 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -public final class EventmeshClient { - private EventmeshClient() { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_RequestHeader_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_RequestHeader_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_Message_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_Message_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_Response_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_Response_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_Subscription_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_Subscription_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_Subscription_SubscriptionItem_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_Heartbeat_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_Heartbeat_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_Heartbeat_HeartbeatItem_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - - static { - String[] descriptorData = { - "\n\026eventmesh-client.proto\022\020eventmesh.clie" + - "nt\"\266\001\n\rRequestHeader\022\013\n\003env\030\001 \001(\t\022\016\n\006reg" + - "ion\030\002 \001(\t\022\013\n\003idc\030\003 \001(\t\022\n\n\002ip\030\004 \001(\t\022\013\n\003pi" + - "d\030\005 \001(\t\022\013\n\003sys\030\006 \001(\t\022\020\n\010username\030\007 \001(\t\022\020" + - "\n\010password\030\010 \001(\t\022\017\n\007version\030\t \001(\t\022\020\n\010lan" + - "guage\030\n \001(\t\022\016\n\006seqNum\030\013 \001(\t\"\222\001\n\007Message\022" + - "/\n\006header\030\001 \001(\0132\037.eventmesh.client.Reque" + - "stHeader\022\027\n\017productionGroup\030\002 \001(\t\022\r\n\005top" + - "ic\030\003 \001(\t\022\017\n\007content\030\004 \001(\t\022\013\n\003ttl\030\005 \001(\t\022\020" + - "\n\010uniqueId\030\006 \001(\t\"O\n\010Response\022\020\n\010respCode" + - "\030\001 \001(\t\022\017\n\007respMsg\030\002 \001(\t\022\020\n\010respTime\030\003 \001(" + - "\t\022\016\n\006seqNum\030\004 \001(\t\"\356\001\n\014Subscription\022/\n\006he" + - "ader\030\001 \001(\0132\037.eventmesh.client.RequestHea" + - "der\022\025\n\rconsumerGroup\030\002 \001(\t\022J\n\021subscripti" + - "onItems\030\003 \003(\0132/.eventmesh.client.Subscri" + - "ption.SubscriptionItem\032J\n\020SubscriptionIt" + - "em\022\r\n\005topic\030\001 \001(\t\022\014\n\004mode\030\002 \001(\t\022\014\n\004type\030" + - "\003 \001(\t\022\013\n\003url\030\004 \001(\t\"\356\001\n\tHeartbeat\022/\n\006head" + - "er\030\001 \001(\0132\037.eventmesh.client.RequestHeade" + - "r\022\022\n\nclientType\030\002 \001(\t\022\025\n\rproducerGroup\030\003" + - " \001(\t\022\025\n\rconsumerGroup\030\004 \001(\t\022A\n\016heartbeat" + - "Items\030\005 \003(\0132).eventmesh.client.Heartbeat" + - ".HeartbeatItem\032+\n\rHeartbeatItem\022\r\n\005topic" + - "\030\001 \001(\t\022\013\n\003url\030\002 \001(\t2\337\001\n\020PublisherService" + - "\022@\n\007publish\022\031.eventmesh.client.Message\032\032" + - ".eventmesh.client.Response\022E\n\014requestRep" + - "ly\022\031.eventmesh.client.Message\032\032.eventmes" + - "h.client.Response\022B\n\tbroadcast\022\031.eventme" + - "sh.client.Message\032\032.eventmesh.client.Res" + - "ponse2\365\001\n\017ConsumerService\022G\n\tsubscribe\022\036" + - ".eventmesh.client.Subscription\032\032.eventme" + - "sh.client.Response\022N\n\017subscribeStream\022\036." + - "eventmesh.client.Subscription\032\031.eventmes" + - "h.client.Message0\001\022I\n\013unsubscribe\022\036.even" + - "tmesh.client.Subscription\032\032.eventmesh.cl" + - "ient.Response2X\n\020HeartbeatService\022D\n\thea" + - "rtbeat\022\033.eventmesh.client.Heartbeat\032\032.ev" + - "entmesh.client.ResponseB<\n\'org.apache.ev" + - "entmesh.client.grpc.protosB\017EventmeshCli" + - "entP\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[]{ - }, assigner); - internal_static_eventmesh_client_RequestHeader_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_eventmesh_client_RequestHeader_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_RequestHeader_descriptor, - new String[]{"Env", "Region", "Idc", "Ip", "Pid", "Sys", "Username", "Password", "Version", "Language", "SeqNum",}); - internal_static_eventmesh_client_Message_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_eventmesh_client_Message_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_Message_descriptor, - new String[]{"Header", "ProductionGroup", "Topic", "Content", "Ttl", "UniqueId",}); - internal_static_eventmesh_client_Response_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_eventmesh_client_Response_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_Response_descriptor, - new String[]{"RespCode", "RespMsg", "RespTime", "SeqNum",}); - internal_static_eventmesh_client_Subscription_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_eventmesh_client_Subscription_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_Subscription_descriptor, - new String[]{"Header", "ConsumerGroup", "SubscriptionItems",}); - internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor = - internal_static_eventmesh_client_Subscription_descriptor.getNestedTypes().get(0); - internal_static_eventmesh_client_Subscription_SubscriptionItem_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor, - new String[]{"Topic", "Mode", "Type", "Url",}); - internal_static_eventmesh_client_Heartbeat_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_eventmesh_client_Heartbeat_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_Heartbeat_descriptor, - new String[]{"Header", "ClientType", "ProducerGroup", "ConsumerGroup", "HeartbeatItems",}); - internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor = - internal_static_eventmesh_client_Heartbeat_descriptor.getNestedTypes().get(0); - internal_static_eventmesh_client_Heartbeat_HeartbeatItem_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor, - new String[]{"Topic", "Url",}); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Heartbeat.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Heartbeat.java deleted file mode 100644 index f9927b7b81..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Heartbeat.java +++ /dev/null @@ -1,2117 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * Protobuf type {@code eventmesh.client.Heartbeat} - */ -public final class Heartbeat extends - com.google.protobuf.GeneratedMessageV3 implements - HeartbeatOrBuilder { - private static final long serialVersionUID = 0L; - - // Use Heartbeat.newBuilder() to construct. - private Heartbeat(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private Heartbeat() { - clientType_ = ""; - producerGroup_ = ""; - consumerGroup_ = ""; - heartbeatItems_ = java.util.Collections.emptyList(); - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private Heartbeat( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - RequestHeader.Builder subBuilder = null; - if (header_ != null) { - subBuilder = header_.toBuilder(); - } - header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(header_); - header_ = subBuilder.buildPartial(); - } - - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - clientType_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - producerGroup_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - consumerGroup_ = s; - break; - } - case 42: { - if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - heartbeatItems_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000010; - } - heartbeatItems_.add( - input.readMessage(HeartbeatItem.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - heartbeatItems_ = java.util.Collections.unmodifiableList(heartbeatItems_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Heartbeat.class, Builder.class); - } - - public interface HeartbeatItemOrBuilder extends - // @@protoc_insertion_point(interface_extends:eventmesh.client.Heartbeat.HeartbeatItem) - com.google.protobuf.MessageOrBuilder { - - /** - * string topic = 1; - */ - String getTopic(); - - /** - * string topic = 1; - */ - com.google.protobuf.ByteString - getTopicBytes(); - - /** - * string url = 2; - */ - String getUrl(); - - /** - * string url = 2; - */ - com.google.protobuf.ByteString - getUrlBytes(); - } - - /** - * Protobuf type {@code eventmesh.client.Heartbeat.HeartbeatItem} - */ - public static final class HeartbeatItem extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:eventmesh.client.Heartbeat.HeartbeatItem) - HeartbeatItemOrBuilder { - private static final long serialVersionUID = 0L; - - // Use HeartbeatItem.newBuilder() to construct. - private HeartbeatItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private HeartbeatItem() { - topic_ = ""; - url_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private HeartbeatItem( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - topic_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - url_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_fieldAccessorTable - .ensureFieldAccessorsInitialized( - HeartbeatItem.class, Builder.class); - } - - public static final int TOPIC_FIELD_NUMBER = 1; - private volatile Object topic_; - - /** - * string topic = 1; - */ - public String getTopic() { - Object ref = topic_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - topic_ = s; - return s; - } - } - - /** - * string topic = 1; - */ - public com.google.protobuf.ByteString - getTopicBytes() { - Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int URL_FIELD_NUMBER = 2; - private volatile Object url_; - - /** - * string url = 2; - */ - public String getUrl() { - Object ref = url_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - url_ = s; - return s; - } - } - - /** - * string url = 2; - */ - public com.google.protobuf.ByteString - getUrlBytes() { - Object ref = url_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - url_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getTopicBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); - } - if (!getUrlBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, url_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getTopicBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); - } - if (!getUrlBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, url_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof HeartbeatItem)) { - return super.equals(obj); - } - HeartbeatItem other = (HeartbeatItem) obj; - - boolean result = true; - result = result && getTopic() - .equals(other.getTopic()); - result = result && getUrl() - .equals(other.getUrl()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + TOPIC_FIELD_NUMBER; - hash = (53 * hash) + getTopic().hashCode(); - hash = (37 * hash) + URL_FIELD_NUMBER; - hash = (53 * hash) + getUrl().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static HeartbeatItem parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static HeartbeatItem parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static HeartbeatItem parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static HeartbeatItem parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static HeartbeatItem parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static HeartbeatItem parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static HeartbeatItem parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static HeartbeatItem parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static HeartbeatItem parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static HeartbeatItem parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static HeartbeatItem parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static HeartbeatItem parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(HeartbeatItem prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.Heartbeat.HeartbeatItem} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.Heartbeat.HeartbeatItem) - HeartbeatItemOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_fieldAccessorTable - .ensureFieldAccessorsInitialized( - HeartbeatItem.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.Heartbeat.HeartbeatItem.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - public Builder clear() { - super.clear(); - topic_ = ""; - - url_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor; - } - - public HeartbeatItem getDefaultInstanceForType() { - return HeartbeatItem.getDefaultInstance(); - } - - public HeartbeatItem build() { - HeartbeatItem result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public HeartbeatItem buildPartial() { - HeartbeatItem result = new HeartbeatItem(this); - result.topic_ = topic_; - result.url_ = url_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof HeartbeatItem) { - return mergeFrom((HeartbeatItem) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(HeartbeatItem other) { - if (other == HeartbeatItem.getDefaultInstance()) return this; - if (!other.getTopic().isEmpty()) { - topic_ = other.topic_; - onChanged(); - } - if (!other.getUrl().isEmpty()) { - url_ = other.url_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - HeartbeatItem parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (HeartbeatItem) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private Object topic_ = ""; - - /** - * string topic = 1; - */ - public String getTopic() { - Object ref = topic_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - topic_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string topic = 1; - */ - public com.google.protobuf.ByteString - getTopicBytes() { - Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string topic = 1; - */ - public Builder setTopic( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - topic_ = value; - onChanged(); - return this; - } - - /** - * string topic = 1; - */ - public Builder clearTopic() { - - topic_ = getDefaultInstance().getTopic(); - onChanged(); - return this; - } - - /** - * string topic = 1; - */ - public Builder setTopicBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - topic_ = value; - onChanged(); - return this; - } - - private Object url_ = ""; - - /** - * string url = 2; - */ - public String getUrl() { - Object ref = url_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - url_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string url = 2; - */ - public com.google.protobuf.ByteString - getUrlBytes() { - Object ref = url_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - url_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string url = 2; - */ - public Builder setUrl( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - url_ = value; - onChanged(); - return this; - } - - /** - * string url = 2; - */ - public Builder clearUrl() { - - url_ = getDefaultInstance().getUrl(); - onChanged(); - return this; - } - - /** - * string url = 2; - */ - public Builder setUrlBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - url_ = value; - onChanged(); - return this; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.Heartbeat.HeartbeatItem) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.Heartbeat.HeartbeatItem) - private static final HeartbeatItem DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new HeartbeatItem(); - } - - public static HeartbeatItem getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public HeartbeatItem parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new HeartbeatItem(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public HeartbeatItem getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private int bitField0_; - public static final int HEADER_FIELD_NUMBER = 1; - private RequestHeader header_; - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public boolean hasHeader() { - return header_ != null; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader getHeader() { - return header_ == null ? RequestHeader.getDefaultInstance() : header_; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeaderOrBuilder getHeaderOrBuilder() { - return getHeader(); - } - - public static final int CLIENTTYPE_FIELD_NUMBER = 2; - private volatile Object clientType_; - - /** - * string clientType = 2; - */ - public String getClientType() { - Object ref = clientType_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - clientType_ = s; - return s; - } - } - - /** - * string clientType = 2; - */ - public com.google.protobuf.ByteString - getClientTypeBytes() { - Object ref = clientType_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - clientType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PRODUCERGROUP_FIELD_NUMBER = 3; - private volatile Object producerGroup_; - - /** - * string producerGroup = 3; - */ - public String getProducerGroup() { - Object ref = producerGroup_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - producerGroup_ = s; - return s; - } - } - - /** - * string producerGroup = 3; - */ - public com.google.protobuf.ByteString - getProducerGroupBytes() { - Object ref = producerGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - producerGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int CONSUMERGROUP_FIELD_NUMBER = 4; - private volatile Object consumerGroup_; - - /** - * string consumerGroup = 4; - */ - public String getConsumerGroup() { - Object ref = consumerGroup_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - consumerGroup_ = s; - return s; - } - } - - /** - * string consumerGroup = 4; - */ - public com.google.protobuf.ByteString - getConsumerGroupBytes() { - Object ref = consumerGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - consumerGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int HEARTBEATITEMS_FIELD_NUMBER = 5; - private java.util.List heartbeatItems_; - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public java.util.List getHeartbeatItemsList() { - return heartbeatItems_; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public java.util.List - getHeartbeatItemsOrBuilderList() { - return heartbeatItems_; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public int getHeartbeatItemsCount() { - return heartbeatItems_.size(); - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItem getHeartbeatItems(int index) { - return heartbeatItems_.get(index); - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder( - int index) { - return heartbeatItems_.get(index); - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (header_ != null) { - output.writeMessage(1, getHeader()); - } - if (!getClientTypeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, clientType_); - } - if (!getProducerGroupBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, producerGroup_); - } - if (!getConsumerGroupBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, consumerGroup_); - } - for (int i = 0; i < heartbeatItems_.size(); i++) { - output.writeMessage(5, heartbeatItems_.get(i)); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (header_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getHeader()); - } - if (!getClientTypeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, clientType_); - } - if (!getProducerGroupBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, producerGroup_); - } - if (!getConsumerGroupBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, consumerGroup_); - } - for (int i = 0; i < heartbeatItems_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, heartbeatItems_.get(i)); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Heartbeat)) { - return super.equals(obj); - } - Heartbeat other = (Heartbeat) obj; - - boolean result = true; - result = result && (hasHeader() == other.hasHeader()); - if (hasHeader()) { - result = result && getHeader() - .equals(other.getHeader()); - } - result = result && getClientType() - .equals(other.getClientType()); - result = result && getProducerGroup() - .equals(other.getProducerGroup()); - result = result && getConsumerGroup() - .equals(other.getConsumerGroup()); - result = result && getHeartbeatItemsList() - .equals(other.getHeartbeatItemsList()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasHeader()) { - hash = (37 * hash) + HEADER_FIELD_NUMBER; - hash = (53 * hash) + getHeader().hashCode(); - } - hash = (37 * hash) + CLIENTTYPE_FIELD_NUMBER; - hash = (53 * hash) + getClientType().hashCode(); - hash = (37 * hash) + PRODUCERGROUP_FIELD_NUMBER; - hash = (53 * hash) + getProducerGroup().hashCode(); - hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER; - hash = (53 * hash) + getConsumerGroup().hashCode(); - if (getHeartbeatItemsCount() > 0) { - hash = (37 * hash) + HEARTBEATITEMS_FIELD_NUMBER; - hash = (53 * hash) + getHeartbeatItemsList().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static Heartbeat parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Heartbeat parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Heartbeat parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Heartbeat parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Heartbeat parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Heartbeat parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Heartbeat parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Heartbeat parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static Heartbeat parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static Heartbeat parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static Heartbeat parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Heartbeat parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(Heartbeat prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.Heartbeat} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.Heartbeat) - HeartbeatOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Heartbeat.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.Heartbeat.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - getHeartbeatItemsFieldBuilder(); - } - } - - public Builder clear() { - super.clear(); - if (headerBuilder_ == null) { - header_ = null; - } else { - header_ = null; - headerBuilder_ = null; - } - clientType_ = ""; - - producerGroup_ = ""; - - consumerGroup_ = ""; - - if (heartbeatItemsBuilder_ == null) { - heartbeatItems_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - } else { - heartbeatItemsBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_descriptor; - } - - public Heartbeat getDefaultInstanceForType() { - return Heartbeat.getDefaultInstance(); - } - - public Heartbeat build() { - Heartbeat result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Heartbeat buildPartial() { - Heartbeat result = new Heartbeat(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (headerBuilder_ == null) { - result.header_ = header_; - } else { - result.header_ = headerBuilder_.build(); - } - result.clientType_ = clientType_; - result.producerGroup_ = producerGroup_; - result.consumerGroup_ = consumerGroup_; - if (heartbeatItemsBuilder_ == null) { - if (((bitField0_ & 0x00000010) == 0x00000010)) { - heartbeatItems_ = java.util.Collections.unmodifiableList(heartbeatItems_); - bitField0_ = (bitField0_ & ~0x00000010); - } - result.heartbeatItems_ = heartbeatItems_; - } else { - result.heartbeatItems_ = heartbeatItemsBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Heartbeat) { - return mergeFrom((Heartbeat) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(Heartbeat other) { - if (other == Heartbeat.getDefaultInstance()) return this; - if (other.hasHeader()) { - mergeHeader(other.getHeader()); - } - if (!other.getClientType().isEmpty()) { - clientType_ = other.clientType_; - onChanged(); - } - if (!other.getProducerGroup().isEmpty()) { - producerGroup_ = other.producerGroup_; - onChanged(); - } - if (!other.getConsumerGroup().isEmpty()) { - consumerGroup_ = other.consumerGroup_; - onChanged(); - } - if (heartbeatItemsBuilder_ == null) { - if (!other.heartbeatItems_.isEmpty()) { - if (heartbeatItems_.isEmpty()) { - heartbeatItems_ = other.heartbeatItems_; - bitField0_ = (bitField0_ & ~0x00000010); - } else { - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.addAll(other.heartbeatItems_); - } - onChanged(); - } - } else { - if (!other.heartbeatItems_.isEmpty()) { - if (heartbeatItemsBuilder_.isEmpty()) { - heartbeatItemsBuilder_.dispose(); - heartbeatItemsBuilder_ = null; - heartbeatItems_ = other.heartbeatItems_; - bitField0_ = (bitField0_ & ~0x00000010); - heartbeatItemsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getHeartbeatItemsFieldBuilder() : null; - } else { - heartbeatItemsBuilder_.addAllMessages(other.heartbeatItems_); - } - } - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Heartbeat parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Heartbeat) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int bitField0_; - - private RequestHeader header_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public boolean hasHeader() { - return headerBuilder_ != null || header_ != null; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader getHeader() { - if (headerBuilder_ == null) { - return header_ == null ? RequestHeader.getDefaultInstance() : header_; - } else { - return headerBuilder_.getMessage(); - } - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder setHeader(RequestHeader value) { - if (headerBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - header_ = value; - onChanged(); - } else { - headerBuilder_.setMessage(value); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder setHeader( - RequestHeader.Builder builderForValue) { - if (headerBuilder_ == null) { - header_ = builderForValue.build(); - onChanged(); - } else { - headerBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder mergeHeader(RequestHeader value) { - if (headerBuilder_ == null) { - if (header_ != null) { - header_ = - RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); - } else { - header_ = value; - } - onChanged(); - } else { - headerBuilder_.mergeFrom(value); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder clearHeader() { - if (headerBuilder_ == null) { - header_ = null; - onChanged(); - } else { - header_ = null; - headerBuilder_ = null; - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader.Builder getHeaderBuilder() { - - onChanged(); - return getHeaderFieldBuilder().getBuilder(); - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeaderOrBuilder getHeaderOrBuilder() { - if (headerBuilder_ != null) { - return headerBuilder_.getMessageOrBuilder(); - } else { - return header_ == null ? - RequestHeader.getDefaultInstance() : header_; - } - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> - getHeaderFieldBuilder() { - if (headerBuilder_ == null) { - headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( - getHeader(), - getParentForChildren(), - isClean()); - header_ = null; - } - return headerBuilder_; - } - - private Object clientType_ = ""; - - /** - * string clientType = 2; - */ - public String getClientType() { - Object ref = clientType_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - clientType_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string clientType = 2; - */ - public com.google.protobuf.ByteString - getClientTypeBytes() { - Object ref = clientType_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - clientType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string clientType = 2; - */ - public Builder setClientType( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - clientType_ = value; - onChanged(); - return this; - } - - /** - * string clientType = 2; - */ - public Builder clearClientType() { - - clientType_ = getDefaultInstance().getClientType(); - onChanged(); - return this; - } - - /** - * string clientType = 2; - */ - public Builder setClientTypeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - clientType_ = value; - onChanged(); - return this; - } - - private Object producerGroup_ = ""; - - /** - * string producerGroup = 3; - */ - public String getProducerGroup() { - Object ref = producerGroup_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - producerGroup_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string producerGroup = 3; - */ - public com.google.protobuf.ByteString - getProducerGroupBytes() { - Object ref = producerGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - producerGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string producerGroup = 3; - */ - public Builder setProducerGroup( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - producerGroup_ = value; - onChanged(); - return this; - } - - /** - * string producerGroup = 3; - */ - public Builder clearProducerGroup() { - - producerGroup_ = getDefaultInstance().getProducerGroup(); - onChanged(); - return this; - } - - /** - * string producerGroup = 3; - */ - public Builder setProducerGroupBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - producerGroup_ = value; - onChanged(); - return this; - } - - private Object consumerGroup_ = ""; - - /** - * string consumerGroup = 4; - */ - public String getConsumerGroup() { - Object ref = consumerGroup_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - consumerGroup_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string consumerGroup = 4; - */ - public com.google.protobuf.ByteString - getConsumerGroupBytes() { - Object ref = consumerGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - consumerGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string consumerGroup = 4; - */ - public Builder setConsumerGroup( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - consumerGroup_ = value; - onChanged(); - return this; - } - - /** - * string consumerGroup = 4; - */ - public Builder clearConsumerGroup() { - - consumerGroup_ = getDefaultInstance().getConsumerGroup(); - onChanged(); - return this; - } - - /** - * string consumerGroup = 4; - */ - public Builder setConsumerGroupBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - consumerGroup_ = value; - onChanged(); - return this; - } - - private java.util.List heartbeatItems_ = - java.util.Collections.emptyList(); - - private void ensureHeartbeatItemsIsMutable() { - if (!((bitField0_ & 0x00000010) == 0x00000010)) { - heartbeatItems_ = new java.util.ArrayList(heartbeatItems_); - bitField0_ |= 0x00000010; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder> heartbeatItemsBuilder_; - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public java.util.List getHeartbeatItemsList() { - if (heartbeatItemsBuilder_ == null) { - return java.util.Collections.unmodifiableList(heartbeatItems_); - } else { - return heartbeatItemsBuilder_.getMessageList(); - } - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public int getHeartbeatItemsCount() { - if (heartbeatItemsBuilder_ == null) { - return heartbeatItems_.size(); - } else { - return heartbeatItemsBuilder_.getCount(); - } - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItem getHeartbeatItems(int index) { - if (heartbeatItemsBuilder_ == null) { - return heartbeatItems_.get(index); - } else { - return heartbeatItemsBuilder_.getMessage(index); - } - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder setHeartbeatItems( - int index, HeartbeatItem value) { - if (heartbeatItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.set(index, value); - onChanged(); - } else { - heartbeatItemsBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder setHeartbeatItems( - int index, HeartbeatItem.Builder builderForValue) { - if (heartbeatItemsBuilder_ == null) { - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.set(index, builderForValue.build()); - onChanged(); - } else { - heartbeatItemsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder addHeartbeatItems(HeartbeatItem value) { - if (heartbeatItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.add(value); - onChanged(); - } else { - heartbeatItemsBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder addHeartbeatItems( - int index, HeartbeatItem value) { - if (heartbeatItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.add(index, value); - onChanged(); - } else { - heartbeatItemsBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder addHeartbeatItems( - HeartbeatItem.Builder builderForValue) { - if (heartbeatItemsBuilder_ == null) { - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.add(builderForValue.build()); - onChanged(); - } else { - heartbeatItemsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder addHeartbeatItems( - int index, HeartbeatItem.Builder builderForValue) { - if (heartbeatItemsBuilder_ == null) { - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.add(index, builderForValue.build()); - onChanged(); - } else { - heartbeatItemsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder addAllHeartbeatItems( - Iterable values) { - if (heartbeatItemsBuilder_ == null) { - ensureHeartbeatItemsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, heartbeatItems_); - onChanged(); - } else { - heartbeatItemsBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder clearHeartbeatItems() { - if (heartbeatItemsBuilder_ == null) { - heartbeatItems_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - onChanged(); - } else { - heartbeatItemsBuilder_.clear(); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder removeHeartbeatItems(int index) { - if (heartbeatItemsBuilder_ == null) { - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.remove(index); - onChanged(); - } else { - heartbeatItemsBuilder_.remove(index); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItem.Builder getHeartbeatItemsBuilder( - int index) { - return getHeartbeatItemsFieldBuilder().getBuilder(index); - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder( - int index) { - if (heartbeatItemsBuilder_ == null) { - return heartbeatItems_.get(index); - } else { - return heartbeatItemsBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public java.util.List - getHeartbeatItemsOrBuilderList() { - if (heartbeatItemsBuilder_ != null) { - return heartbeatItemsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(heartbeatItems_); - } - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItem.Builder addHeartbeatItemsBuilder() { - return getHeartbeatItemsFieldBuilder().addBuilder( - HeartbeatItem.getDefaultInstance()); - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItem.Builder addHeartbeatItemsBuilder( - int index) { - return getHeartbeatItemsFieldBuilder().addBuilder( - index, HeartbeatItem.getDefaultInstance()); - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public java.util.List - getHeartbeatItemsBuilderList() { - return getHeartbeatItemsFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder> - getHeartbeatItemsFieldBuilder() { - if (heartbeatItemsBuilder_ == null) { - heartbeatItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder>( - heartbeatItems_, - ((bitField0_ & 0x00000010) == 0x00000010), - getParentForChildren(), - isClean()); - heartbeatItems_ = null; - } - return heartbeatItemsBuilder_; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.Heartbeat) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.Heartbeat) - private static final Heartbeat DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new Heartbeat(); - } - - public static Heartbeat getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Heartbeat parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Heartbeat(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public Heartbeat getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatOrBuilder.java deleted file mode 100644 index ec67c09c33..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatOrBuilder.java +++ /dev/null @@ -1,97 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * HeartbeatOrBuilder interface. - */ -public interface HeartbeatOrBuilder extends com.google.protobuf.MessageOrBuilder { - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - boolean hasHeader(); - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - RequestHeader getHeader(); - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - RequestHeaderOrBuilder getHeaderOrBuilder(); - - /** - * string clientType = 2. - */ - String getClientType(); - - /** - * string clientType = 2. - */ - com.google.protobuf.ByteString getClientTypeBytes(); - - /** - * string producerGroup = 3. - */ - String getProducerGroup(); - - /** - * string producerGroup = 3. - */ - com.google.protobuf.ByteString getProducerGroupBytes(); - - /** - * string consumerGroup = 4. - */ - String getConsumerGroup(); - - /** - * string consumerGroup = 4. - */ - com.google.protobuf.ByteString getConsumerGroupBytes(); - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. - */ - java.util.List getHeartbeatItemsList(); - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. - */ - Heartbeat.HeartbeatItem getHeartbeatItems(int index); - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. - */ - int getHeartbeatItemsCount(); - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. - */ - java.util.List getHeartbeatItemsOrBuilderList(); - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. - */ - Heartbeat.HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder(int index); -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatServiceGrpc.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatServiceGrpc.java deleted file mode 100644 index 40df4200ab..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatServiceGrpc.java +++ /dev/null @@ -1,302 +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 org.apache.eventmesh.client.grpc.protos; - -import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.blockingUnaryCall; -import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; - -/** - * - */ -@javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.15.0)", - comments = "Source: eventmesh-client.proto") -public final class HeartbeatServiceGrpc { - - private HeartbeatServiceGrpc() { - } - - public static final String SERVICE_NAME = "eventmesh.client.HeartbeatService"; - - // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getHeartbeatMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "heartbeat", - requestType = org.apache.eventmesh.client.grpc.protos.Heartbeat.class, - responseType = org.apache.eventmesh.client.grpc.protos.Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getHeartbeatMethod() { - io.grpc.MethodDescriptor getHeartbeatMethod; - if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { - synchronized (HeartbeatServiceGrpc.class) { - if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { - HeartbeatServiceGrpc.getHeartbeatMethod = getHeartbeatMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.HeartbeatService", "heartbeat")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Heartbeat.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) - .setSchemaDescriptor(new HeartbeatServiceMethodDescriptorSupplier("heartbeat")) - .build(); - } - } - } - return getHeartbeatMethod; - } - - /** - * Creates a new async stub that supports all call types for the service - */ - public static HeartbeatServiceStub newStub(io.grpc.Channel channel) { - return new HeartbeatServiceStub(channel); - } - - /** - * Creates a new blocking-style stub that supports unary and streaming output calls on the service - */ - public static HeartbeatServiceBlockingStub newBlockingStub( - io.grpc.Channel channel) { - return new HeartbeatServiceBlockingStub(channel); - } - - /** - * Creates a new ListenableFuture-style stub that supports unary calls on the service - */ - public static HeartbeatServiceFutureStub newFutureStub( - io.grpc.Channel channel) { - return new HeartbeatServiceFutureStub(channel); - } - - /** - * - */ - public static abstract class HeartbeatServiceImplBase implements io.grpc.BindableService { - - /** - * - */ - public void heartbeat(org.apache.eventmesh.client.grpc.protos.Heartbeat request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getHeartbeatMethod(), responseObserver); - } - - @Override - public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getHeartbeatMethod(), - asyncUnaryCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Heartbeat, - org.apache.eventmesh.client.grpc.protos.Response>( - this, METHODID_HEARTBEAT))) - .build(); - } - } - - /** - * - */ - public static final class HeartbeatServiceStub extends io.grpc.stub.AbstractStub { - private HeartbeatServiceStub(io.grpc.Channel channel) { - super(channel); - } - - private HeartbeatServiceStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected HeartbeatServiceStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new HeartbeatServiceStub(channel, callOptions); - } - - /** - * - */ - public void heartbeat(org.apache.eventmesh.client.grpc.protos.Heartbeat request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request, responseObserver); - } - } - - /** - * - */ - public static final class HeartbeatServiceBlockingStub extends io.grpc.stub.AbstractStub { - private HeartbeatServiceBlockingStub(io.grpc.Channel channel) { - super(channel); - } - - private HeartbeatServiceBlockingStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected HeartbeatServiceBlockingStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new HeartbeatServiceBlockingStub(channel, callOptions); - } - - /** - * - */ - public org.apache.eventmesh.client.grpc.protos.Response heartbeat(org.apache.eventmesh.client.grpc.protos.Heartbeat request) { - return blockingUnaryCall( - getChannel(), getHeartbeatMethod(), getCallOptions(), request); - } - } - - /** - * - */ - public static final class HeartbeatServiceFutureStub extends io.grpc.stub.AbstractStub { - private HeartbeatServiceFutureStub(io.grpc.Channel channel) { - super(channel); - } - - private HeartbeatServiceFutureStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected HeartbeatServiceFutureStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new HeartbeatServiceFutureStub(channel, callOptions); - } - - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture heartbeat( - org.apache.eventmesh.client.grpc.protos.Heartbeat request) { - return futureUnaryCall( - getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request); - } - } - - private static final int METHODID_HEARTBEAT = 0; - - private static final class MethodHandlers implements - io.grpc.stub.ServerCalls.UnaryMethod, - io.grpc.stub.ServerCalls.ServerStreamingMethod, - io.grpc.stub.ServerCalls.ClientStreamingMethod, - io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final HeartbeatServiceImplBase serviceImpl; - private final int methodId; - - MethodHandlers(HeartbeatServiceImplBase serviceImpl, int methodId) { - this.serviceImpl = serviceImpl; - this.methodId = methodId; - } - - @Override - @SuppressWarnings("unchecked") - public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - case METHODID_HEARTBEAT: - serviceImpl.heartbeat((org.apache.eventmesh.client.grpc.protos.Heartbeat) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - default: - throw new AssertionError(); - } - } - - @Override - @SuppressWarnings("unchecked") - public io.grpc.stub.StreamObserver invoke( - io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - default: - throw new AssertionError(); - } - } - } - - private static abstract class HeartbeatServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { - HeartbeatServiceBaseDescriptorSupplier() { - } - - @Override - public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { - return org.apache.eventmesh.client.grpc.protos.EventmeshClient.getDescriptor(); - } - - @Override - public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { - return getFileDescriptor().findServiceByName("HeartbeatService"); - } - } - - private static final class HeartbeatServiceFileDescriptorSupplier - extends HeartbeatServiceBaseDescriptorSupplier { - HeartbeatServiceFileDescriptorSupplier() { - } - } - - private static final class HeartbeatServiceMethodDescriptorSupplier - extends HeartbeatServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { - private final String methodName; - - HeartbeatServiceMethodDescriptorSupplier(String methodName) { - this.methodName = methodName; - } - - @Override - public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { - return getServiceDescriptor().findMethodByName(methodName); - } - } - - private static volatile io.grpc.ServiceDescriptor serviceDescriptor; - - public static io.grpc.ServiceDescriptor getServiceDescriptor() { - io.grpc.ServiceDescriptor result = serviceDescriptor; - if (result == null) { - synchronized (HeartbeatServiceGrpc.class) { - result = serviceDescriptor; - if (result == null) { - serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) - .setSchemaDescriptor(new HeartbeatServiceFileDescriptorSupplier()) - .addMethod(getHeartbeatMethod()) - .build(); - } - } - } - return result; - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Message.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Message.java deleted file mode 100644 index ecef2824ff..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Message.java +++ /dev/null @@ -1,1299 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * Protobuf type {@code eventmesh.client.Message} - */ -public final class Message extends - com.google.protobuf.GeneratedMessageV3 implements MessageOrBuilder { - private static final long serialVersionUID = 0L; - - // Use Message.newBuilder() to construct. - private Message(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private Message() { - productionGroup_ = ""; - topic_ = ""; - content_ = ""; - ttl_ = ""; - uniqueId_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private Message( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - RequestHeader.Builder subBuilder = null; - if (header_ != null) { - subBuilder = header_.toBuilder(); - } - header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(header_); - header_ = subBuilder.buildPartial(); - } - - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - productionGroup_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - topic_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - content_ = s; - break; - } - case 42: { - String s = input.readStringRequireUtf8(); - - ttl_ = s; - break; - } - case 50: { - String s = input.readStringRequireUtf8(); - - uniqueId_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Message_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Message_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Message.class, Builder.class); - } - - public static final int HEADER_FIELD_NUMBER = 1; - private RequestHeader header_; - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public boolean hasHeader() { - return header_ != null; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader getHeader() { - return header_ == null ? RequestHeader.getDefaultInstance() : header_; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeaderOrBuilder getHeaderOrBuilder() { - return getHeader(); - } - - public static final int PRODUCTIONGROUP_FIELD_NUMBER = 2; - private volatile Object productionGroup_; - - /** - * string productionGroup = 2; - */ - public String getProductionGroup() { - Object ref = productionGroup_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - productionGroup_ = s; - return s; - } - } - - /** - * string productionGroup = 2; - */ - public com.google.protobuf.ByteString - getProductionGroupBytes() { - Object ref = productionGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - productionGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TOPIC_FIELD_NUMBER = 3; - private volatile Object topic_; - - /** - * string topic = 3; - */ - public String getTopic() { - Object ref = topic_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - topic_ = s; - return s; - } - } - - /** - * string topic = 3; - */ - public com.google.protobuf.ByteString - getTopicBytes() { - Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int CONTENT_FIELD_NUMBER = 4; - private volatile Object content_; - - /** - * string content = 4; - */ - public String getContent() { - Object ref = content_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - content_ = s; - return s; - } - } - - /** - * string content = 4; - */ - public com.google.protobuf.ByteString - getContentBytes() { - Object ref = content_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - content_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TTL_FIELD_NUMBER = 5; - private volatile Object ttl_; - - /** - * string ttl = 5; - */ - public String getTtl() { - Object ref = ttl_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - ttl_ = s; - return s; - } - } - - /** - * string ttl = 5; - */ - public com.google.protobuf.ByteString - getTtlBytes() { - Object ref = ttl_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - ttl_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int UNIQUEID_FIELD_NUMBER = 6; - private volatile Object uniqueId_; - - /** - * string uniqueId = 6; - */ - public String getUniqueId() { - Object ref = uniqueId_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - uniqueId_ = s; - return s; - } - } - - /** - * string uniqueId = 6; - */ - public com.google.protobuf.ByteString - getUniqueIdBytes() { - Object ref = uniqueId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - uniqueId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (header_ != null) { - output.writeMessage(1, getHeader()); - } - if (!getProductionGroupBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, productionGroup_); - } - if (!getTopicBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, topic_); - } - if (!getContentBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, content_); - } - if (!getTtlBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 5, ttl_); - } - if (!getUniqueIdBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 6, uniqueId_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (header_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getHeader()); - } - if (!getProductionGroupBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, productionGroup_); - } - if (!getTopicBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, topic_); - } - if (!getContentBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, content_); - } - if (!getTtlBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, ttl_); - } - if (!getUniqueIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, uniqueId_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Message)) { - return super.equals(obj); - } - Message other = (Message) obj; - - boolean result = true; - result = result && (hasHeader() == other.hasHeader()); - if (hasHeader()) { - result = result && getHeader() - .equals(other.getHeader()); - } - result = result && getProductionGroup() - .equals(other.getProductionGroup()); - result = result && getTopic() - .equals(other.getTopic()); - result = result && getContent() - .equals(other.getContent()); - result = result && getTtl() - .equals(other.getTtl()); - result = result && getUniqueId() - .equals(other.getUniqueId()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasHeader()) { - hash = (37 * hash) + HEADER_FIELD_NUMBER; - hash = (53 * hash) + getHeader().hashCode(); - } - hash = (37 * hash) + PRODUCTIONGROUP_FIELD_NUMBER; - hash = (53 * hash) + getProductionGroup().hashCode(); - hash = (37 * hash) + TOPIC_FIELD_NUMBER; - hash = (53 * hash) + getTopic().hashCode(); - hash = (37 * hash) + CONTENT_FIELD_NUMBER; - hash = (53 * hash) + getContent().hashCode(); - hash = (37 * hash) + TTL_FIELD_NUMBER; - hash = (53 * hash) + getTtl().hashCode(); - hash = (37 * hash) + UNIQUEID_FIELD_NUMBER; - hash = (53 * hash) + getUniqueId().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static Message parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Message parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Message parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Message parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Message parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Message parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Message parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Message parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static Message parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static Message parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static Message parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Message parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(Message prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.Message} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.Message) - MessageOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Message_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Message_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Message.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.Message.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - public Builder clear() { - super.clear(); - if (headerBuilder_ == null) { - header_ = null; - } else { - header_ = null; - headerBuilder_ = null; - } - productionGroup_ = ""; - - topic_ = ""; - - content_ = ""; - - ttl_ = ""; - - uniqueId_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_Message_descriptor; - } - - public Message getDefaultInstanceForType() { - return Message.getDefaultInstance(); - } - - public Message build() { - Message result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Message buildPartial() { - Message result = new Message(this); - if (headerBuilder_ == null) { - result.header_ = header_; - } else { - result.header_ = headerBuilder_.build(); - } - result.productionGroup_ = productionGroup_; - result.topic_ = topic_; - result.content_ = content_; - result.ttl_ = ttl_; - result.uniqueId_ = uniqueId_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Message) { - return mergeFrom((Message) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(Message other) { - if (other == Message.getDefaultInstance()) return this; - if (other.hasHeader()) { - mergeHeader(other.getHeader()); - } - if (!other.getProductionGroup().isEmpty()) { - productionGroup_ = other.productionGroup_; - onChanged(); - } - if (!other.getTopic().isEmpty()) { - topic_ = other.topic_; - onChanged(); - } - if (!other.getContent().isEmpty()) { - content_ = other.content_; - onChanged(); - } - if (!other.getTtl().isEmpty()) { - ttl_ = other.ttl_; - onChanged(); - } - if (!other.getUniqueId().isEmpty()) { - uniqueId_ = other.uniqueId_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Message parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Message) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private RequestHeader header_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public boolean hasHeader() { - return headerBuilder_ != null || header_ != null; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader getHeader() { - if (headerBuilder_ == null) { - return header_ == null ? RequestHeader.getDefaultInstance() : header_; - } else { - return headerBuilder_.getMessage(); - } - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder setHeader(RequestHeader value) { - if (headerBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - header_ = value; - onChanged(); - } else { - headerBuilder_.setMessage(value); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder setHeader( - RequestHeader.Builder builderForValue) { - if (headerBuilder_ == null) { - header_ = builderForValue.build(); - onChanged(); - } else { - headerBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder mergeHeader(RequestHeader value) { - if (headerBuilder_ == null) { - if (header_ != null) { - header_ = - RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); - } else { - header_ = value; - } - onChanged(); - } else { - headerBuilder_.mergeFrom(value); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder clearHeader() { - if (headerBuilder_ == null) { - header_ = null; - onChanged(); - } else { - header_ = null; - headerBuilder_ = null; - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader.Builder getHeaderBuilder() { - - onChanged(); - return getHeaderFieldBuilder().getBuilder(); - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeaderOrBuilder getHeaderOrBuilder() { - if (headerBuilder_ != null) { - return headerBuilder_.getMessageOrBuilder(); - } else { - return header_ == null ? - RequestHeader.getDefaultInstance() : header_; - } - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> - getHeaderFieldBuilder() { - if (headerBuilder_ == null) { - headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( - getHeader(), - getParentForChildren(), - isClean()); - header_ = null; - } - return headerBuilder_; - } - - private Object productionGroup_ = ""; - - /** - * string productionGroup = 2; - */ - public String getProductionGroup() { - Object ref = productionGroup_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - productionGroup_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string productionGroup = 2; - */ - public com.google.protobuf.ByteString - getProductionGroupBytes() { - Object ref = productionGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - productionGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string productionGroup = 2; - */ - public Builder setProductionGroup( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - productionGroup_ = value; - onChanged(); - return this; - } - - /** - * string productionGroup = 2; - */ - public Builder clearProductionGroup() { - - productionGroup_ = getDefaultInstance().getProductionGroup(); - onChanged(); - return this; - } - - /** - * string productionGroup = 2; - */ - public Builder setProductionGroupBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - productionGroup_ = value; - onChanged(); - return this; - } - - private Object topic_ = ""; - - /** - * string topic = 3; - */ - public String getTopic() { - Object ref = topic_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - topic_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string topic = 3; - */ - public com.google.protobuf.ByteString - getTopicBytes() { - Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string topic = 3; - */ - public Builder setTopic( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - topic_ = value; - onChanged(); - return this; - } - - /** - * string topic = 3; - */ - public Builder clearTopic() { - - topic_ = getDefaultInstance().getTopic(); - onChanged(); - return this; - } - - /** - * string topic = 3; - */ - public Builder setTopicBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - topic_ = value; - onChanged(); - return this; - } - - private Object content_ = ""; - - /** - * string content = 4; - */ - public String getContent() { - Object ref = content_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - content_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string content = 4; - */ - public com.google.protobuf.ByteString - getContentBytes() { - Object ref = content_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - content_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string content = 4; - */ - public Builder setContent( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - content_ = value; - onChanged(); - return this; - } - - /** - * string content = 4; - */ - public Builder clearContent() { - - content_ = getDefaultInstance().getContent(); - onChanged(); - return this; - } - - /** - * string content = 4; - */ - public Builder setContentBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - content_ = value; - onChanged(); - return this; - } - - private Object ttl_ = ""; - - /** - * string ttl = 5; - */ - public String getTtl() { - Object ref = ttl_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - ttl_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string ttl = 5; - */ - public com.google.protobuf.ByteString - getTtlBytes() { - Object ref = ttl_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - ttl_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string ttl = 5; - */ - public Builder setTtl( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - ttl_ = value; - onChanged(); - return this; - } - - /** - * string ttl = 5; - */ - public Builder clearTtl() { - - ttl_ = getDefaultInstance().getTtl(); - onChanged(); - return this; - } - - /** - * string ttl = 5; - */ - public Builder setTtlBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - ttl_ = value; - onChanged(); - return this; - } - - private Object uniqueId_ = ""; - - /** - * string uniqueId = 6; - */ - public String getUniqueId() { - Object ref = uniqueId_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - uniqueId_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string uniqueId = 6; - */ - public com.google.protobuf.ByteString - getUniqueIdBytes() { - Object ref = uniqueId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - uniqueId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string uniqueId = 6; - */ - public Builder setUniqueId( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - uniqueId_ = value; - onChanged(); - return this; - } - - /** - * string uniqueId = 6; - */ - public Builder clearUniqueId() { - - uniqueId_ = getDefaultInstance().getUniqueId(); - onChanged(); - return this; - } - - /** - * string uniqueId = 6; - */ - public Builder setUniqueIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - uniqueId_ = value; - onChanged(); - return this; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.Message) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.Message) - private static final Message DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new Message(); - } - - public static Message getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Message parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Message(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public Message getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/MessageOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/MessageOrBuilder.java deleted file mode 100644 index 05dfb84241..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/MessageOrBuilder.java +++ /dev/null @@ -1,92 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * MessageOrBuilder interface. - */ -public interface MessageOrBuilder extends com.google.protobuf.MessageOrBuilder { - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - boolean hasHeader(); - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - RequestHeader getHeader(); - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - RequestHeaderOrBuilder getHeaderOrBuilder(); - - /** - * string productionGroup = 2. - */ - String getProductionGroup(); - - /** - * string productionGroup = 2. - */ - com.google.protobuf.ByteString getProductionGroupBytes(); - - /** - * string topic = 3. - */ - String getTopic(); - - /** - * string topic = 3. - */ - com.google.protobuf.ByteString getTopicBytes(); - - /** - * string content = 4. - */ - String getContent(); - - /** - * string content = 4. - */ - com.google.protobuf.ByteString getContentBytes(); - - /** - * string ttl = 5. - */ - String getTtl(); - - /** - * string ttl = 5. - */ - com.google.protobuf.ByteString getTtlBytes(); - - /** - * string uniqueId = 6. - */ - String getUniqueId(); - - /** - * string uniqueId = 6. - */ - com.google.protobuf.ByteString getUniqueIdBytes(); -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/PublisherServiceGrpc.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/PublisherServiceGrpc.java deleted file mode 100644 index d075d8fe4b..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/PublisherServiceGrpc.java +++ /dev/null @@ -1,460 +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 org.apache.eventmesh.client.grpc.protos; - -import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.blockingUnaryCall; -import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; - -/** - * - */ -@javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.15.0)", - comments = "Source: eventmesh-client.proto") -public final class PublisherServiceGrpc { - - private PublisherServiceGrpc() { - } - - public static final String SERVICE_NAME = "eventmesh.client.PublisherService"; - - // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getPublishMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "publish", - requestType = org.apache.eventmesh.client.grpc.protos.Message.class, - responseType = org.apache.eventmesh.client.grpc.protos.Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getPublishMethod() { - io.grpc.MethodDescriptor getPublishMethod; - if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { - synchronized (PublisherServiceGrpc.class) { - if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { - PublisherServiceGrpc.getPublishMethod = getPublishMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.PublisherService", "publish")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Message.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) - .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("publish")) - .build(); - } - } - } - return getPublishMethod; - } - - private static volatile io.grpc.MethodDescriptor getRequestReplyMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "requestReply", - requestType = org.apache.eventmesh.client.grpc.protos.Message.class, - responseType = org.apache.eventmesh.client.grpc.protos.Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getRequestReplyMethod() { - io.grpc.MethodDescriptor getRequestReplyMethod; - if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { - synchronized (PublisherServiceGrpc.class) { - if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { - PublisherServiceGrpc.getRequestReplyMethod = getRequestReplyMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.PublisherService", "requestReply")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Message.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) - .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("requestReply")) - .build(); - } - } - } - return getRequestReplyMethod; - } - - private static volatile io.grpc.MethodDescriptor getBroadcastMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "broadcast", - requestType = org.apache.eventmesh.client.grpc.protos.Message.class, - responseType = org.apache.eventmesh.client.grpc.protos.Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getBroadcastMethod() { - io.grpc.MethodDescriptor getBroadcastMethod; - if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { - synchronized (PublisherServiceGrpc.class) { - if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { - PublisherServiceGrpc.getBroadcastMethod = getBroadcastMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.PublisherService", "broadcast")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Message.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) - .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("broadcast")) - .build(); - } - } - } - return getBroadcastMethod; - } - - /** - * Creates a new async stub that supports all call types for the service - */ - public static PublisherServiceStub newStub(io.grpc.Channel channel) { - return new PublisherServiceStub(channel); - } - - /** - * Creates a new blocking-style stub that supports unary and streaming output calls on the service - */ - public static PublisherServiceBlockingStub newBlockingStub( - io.grpc.Channel channel) { - return new PublisherServiceBlockingStub(channel); - } - - /** - * Creates a new ListenableFuture-style stub that supports unary calls on the service - */ - public static PublisherServiceFutureStub newFutureStub( - io.grpc.Channel channel) { - return new PublisherServiceFutureStub(channel); - } - - /** - * - */ - public static abstract class PublisherServiceImplBase implements io.grpc.BindableService { - - /** - * - */ - public void publish(org.apache.eventmesh.client.grpc.protos.Message request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getPublishMethod(), responseObserver); - } - - /** - * - */ - public void requestReply(org.apache.eventmesh.client.grpc.protos.Message request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getRequestReplyMethod(), responseObserver); - } - - /** - * - */ - public void broadcast(org.apache.eventmesh.client.grpc.protos.Message request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getBroadcastMethod(), responseObserver); - } - - @Override - public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getPublishMethod(), - asyncUnaryCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Message, - org.apache.eventmesh.client.grpc.protos.Response>( - this, METHODID_PUBLISH))) - .addMethod( - getRequestReplyMethod(), - asyncUnaryCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Message, - org.apache.eventmesh.client.grpc.protos.Response>( - this, METHODID_REQUEST_REPLY))) - .addMethod( - getBroadcastMethod(), - asyncUnaryCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Message, - org.apache.eventmesh.client.grpc.protos.Response>( - this, METHODID_BROADCAST))) - .build(); - } - } - - /** - * - */ - public static final class PublisherServiceStub extends io.grpc.stub.AbstractStub { - private PublisherServiceStub(io.grpc.Channel channel) { - super(channel); - } - - private PublisherServiceStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected PublisherServiceStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new PublisherServiceStub(channel, callOptions); - } - - /** - * - */ - public void publish(org.apache.eventmesh.client.grpc.protos.Message request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getPublishMethod(), getCallOptions()), request, responseObserver); - } - - /** - * - */ - public void requestReply(org.apache.eventmesh.client.grpc.protos.Message request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request, responseObserver); - } - - /** - * - */ - public void broadcast(org.apache.eventmesh.client.grpc.protos.Message request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getBroadcastMethod(), getCallOptions()), request, responseObserver); - } - } - - /** - * - */ - public static final class PublisherServiceBlockingStub extends io.grpc.stub.AbstractStub { - private PublisherServiceBlockingStub(io.grpc.Channel channel) { - super(channel); - } - - private PublisherServiceBlockingStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected PublisherServiceBlockingStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new PublisherServiceBlockingStub(channel, callOptions); - } - - /** - * - */ - public org.apache.eventmesh.client.grpc.protos.Response publish(org.apache.eventmesh.client.grpc.protos.Message request) { - return blockingUnaryCall( - getChannel(), getPublishMethod(), getCallOptions(), request); - } - - /** - * - */ - public org.apache.eventmesh.client.grpc.protos.Response requestReply(org.apache.eventmesh.client.grpc.protos.Message request) { - return blockingUnaryCall( - getChannel(), getRequestReplyMethod(), getCallOptions(), request); - } - - /** - * - */ - public org.apache.eventmesh.client.grpc.protos.Response broadcast(org.apache.eventmesh.client.grpc.protos.Message request) { - return blockingUnaryCall( - getChannel(), getBroadcastMethod(), getCallOptions(), request); - } - } - - /** - * - */ - public static final class PublisherServiceFutureStub extends io.grpc.stub.AbstractStub { - private PublisherServiceFutureStub(io.grpc.Channel channel) { - super(channel); - } - - private PublisherServiceFutureStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected PublisherServiceFutureStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new PublisherServiceFutureStub(channel, callOptions); - } - - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture publish( - org.apache.eventmesh.client.grpc.protos.Message request) { - return futureUnaryCall( - getChannel().newCall(getPublishMethod(), getCallOptions()), request); - } - - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture requestReply( - org.apache.eventmesh.client.grpc.protos.Message request) { - return futureUnaryCall( - getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request); - } - - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture broadcast( - org.apache.eventmesh.client.grpc.protos.Message request) { - return futureUnaryCall( - getChannel().newCall(getBroadcastMethod(), getCallOptions()), request); - } - } - - private static final int METHODID_PUBLISH = 0; - private static final int METHODID_REQUEST_REPLY = 1; - private static final int METHODID_BROADCAST = 2; - - private static final class MethodHandlers implements - io.grpc.stub.ServerCalls.UnaryMethod, - io.grpc.stub.ServerCalls.ServerStreamingMethod, - io.grpc.stub.ServerCalls.ClientStreamingMethod, - io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final PublisherServiceImplBase serviceImpl; - private final int methodId; - - MethodHandlers(PublisherServiceImplBase serviceImpl, int methodId) { - this.serviceImpl = serviceImpl; - this.methodId = methodId; - } - - @Override - @SuppressWarnings("unchecked") - public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - case METHODID_PUBLISH: - serviceImpl.publish((org.apache.eventmesh.client.grpc.protos.Message) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_REQUEST_REPLY: - serviceImpl.requestReply((org.apache.eventmesh.client.grpc.protos.Message) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_BROADCAST: - serviceImpl.broadcast((org.apache.eventmesh.client.grpc.protos.Message) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - default: - throw new AssertionError(); - } - } - - @Override - @SuppressWarnings("unchecked") - public io.grpc.stub.StreamObserver invoke( - io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - default: - throw new AssertionError(); - } - } - } - - private static abstract class PublisherServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { - PublisherServiceBaseDescriptorSupplier() { - } - - @Override - public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { - return org.apache.eventmesh.client.grpc.protos.EventmeshClient.getDescriptor(); - } - - @Override - public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { - return getFileDescriptor().findServiceByName("PublisherService"); - } - } - - private static final class PublisherServiceFileDescriptorSupplier - extends PublisherServiceBaseDescriptorSupplier { - PublisherServiceFileDescriptorSupplier() { - } - } - - private static final class PublisherServiceMethodDescriptorSupplier - extends PublisherServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { - private final String methodName; - - PublisherServiceMethodDescriptorSupplier(String methodName) { - this.methodName = methodName; - } - - @Override - public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { - return getServiceDescriptor().findMethodByName(methodName); - } - } - - private static volatile io.grpc.ServiceDescriptor serviceDescriptor; - - public static io.grpc.ServiceDescriptor getServiceDescriptor() { - io.grpc.ServiceDescriptor result = serviceDescriptor; - if (result == null) { - synchronized (PublisherServiceGrpc.class) { - result = serviceDescriptor; - if (result == null) { - serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) - .setSchemaDescriptor(new PublisherServiceFileDescriptorSupplier()) - .addMethod(getPublishMethod()) - .addMethod(getRequestReplyMethod()) - .addMethod(getBroadcastMethod()) - .build(); - } - } - } - return result; - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeader.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeader.java deleted file mode 100644 index ed21ed8d35..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeader.java +++ /dev/null @@ -1,1910 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * Protobuf type {@code eventmesh.client.RequestHeader} - */ -public final class RequestHeader extends - com.google.protobuf.GeneratedMessageV3 implements RequestHeaderOrBuilder { - private static final long serialVersionUID = 0L; - - // Use RequestHeader.newBuilder() to construct. - private RequestHeader(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private RequestHeader() { - env_ = ""; - region_ = ""; - idc_ = ""; - ip_ = ""; - pid_ = ""; - sys_ = ""; - username_ = ""; - password_ = ""; - version_ = ""; - language_ = ""; - seqNum_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private RequestHeader( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - env_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - region_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - idc_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - ip_ = s; - break; - } - case 42: { - String s = input.readStringRequireUtf8(); - - pid_ = s; - break; - } - case 50: { - String s = input.readStringRequireUtf8(); - - sys_ = s; - break; - } - case 58: { - String s = input.readStringRequireUtf8(); - - username_ = s; - break; - } - case 66: { - String s = input.readStringRequireUtf8(); - - password_ = s; - break; - } - case 74: { - String s = input.readStringRequireUtf8(); - - version_ = s; - break; - } - case 82: { - String s = input.readStringRequireUtf8(); - - language_ = s; - break; - } - case 90: { - String s = input.readStringRequireUtf8(); - - seqNum_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_RequestHeader_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_RequestHeader_fieldAccessorTable - .ensureFieldAccessorsInitialized( - RequestHeader.class, Builder.class); - } - - public static final int ENV_FIELD_NUMBER = 1; - private volatile Object env_; - - /** - * string env = 1; - */ - public String getEnv() { - Object ref = env_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - env_ = s; - return s; - } - } - - /** - * string env = 1; - */ - public com.google.protobuf.ByteString - getEnvBytes() { - Object ref = env_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - env_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int REGION_FIELD_NUMBER = 2; - private volatile Object region_; - - /** - * string region = 2; - */ - public String getRegion() { - Object ref = region_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - region_ = s; - return s; - } - } - - /** - * string region = 2; - */ - public com.google.protobuf.ByteString - getRegionBytes() { - Object ref = region_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - region_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int IDC_FIELD_NUMBER = 3; - private volatile Object idc_; - - /** - * string idc = 3; - */ - public String getIdc() { - Object ref = idc_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - idc_ = s; - return s; - } - } - - /** - * string idc = 3; - */ - public com.google.protobuf.ByteString - getIdcBytes() { - Object ref = idc_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - idc_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int IP_FIELD_NUMBER = 4; - private volatile Object ip_; - - /** - * string ip = 4; - */ - public String getIp() { - Object ref = ip_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - ip_ = s; - return s; - } - } - - /** - * string ip = 4; - */ - public com.google.protobuf.ByteString - getIpBytes() { - Object ref = ip_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - ip_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PID_FIELD_NUMBER = 5; - private volatile Object pid_; - - /** - * string pid = 5; - */ - public String getPid() { - Object ref = pid_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - pid_ = s; - return s; - } - } - - /** - * string pid = 5; - */ - public com.google.protobuf.ByteString - getPidBytes() { - Object ref = pid_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - pid_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SYS_FIELD_NUMBER = 6; - private volatile Object sys_; - - /** - * string sys = 6; - */ - public String getSys() { - Object ref = sys_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - sys_ = s; - return s; - } - } - - /** - * string sys = 6; - */ - public com.google.protobuf.ByteString - getSysBytes() { - Object ref = sys_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - sys_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int USERNAME_FIELD_NUMBER = 7; - private volatile Object username_; - - /** - * string username = 7; - */ - public String getUsername() { - Object ref = username_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - username_ = s; - return s; - } - } - - /** - * string username = 7; - */ - public com.google.protobuf.ByteString - getUsernameBytes() { - Object ref = username_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - username_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PASSWORD_FIELD_NUMBER = 8; - private volatile Object password_; - - /** - * string password = 8; - */ - public String getPassword() { - Object ref = password_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - password_ = s; - return s; - } - } - - /** - * string password = 8; - */ - public com.google.protobuf.ByteString - getPasswordBytes() { - Object ref = password_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - password_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int VERSION_FIELD_NUMBER = 9; - private volatile Object version_; - - /** - * string version = 9; - */ - public String getVersion() { - Object ref = version_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - version_ = s; - return s; - } - } - - /** - * string version = 9; - */ - public com.google.protobuf.ByteString - getVersionBytes() { - Object ref = version_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - version_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int LANGUAGE_FIELD_NUMBER = 10; - private volatile Object language_; - - /** - * string language = 10; - */ - public String getLanguage() { - Object ref = language_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - language_ = s; - return s; - } - } - - /** - * string language = 10; - */ - public com.google.protobuf.ByteString - getLanguageBytes() { - Object ref = language_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - language_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SEQNUM_FIELD_NUMBER = 11; - private volatile Object seqNum_; - - /** - * string seqNum = 11; - */ - public String getSeqNum() { - Object ref = seqNum_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - seqNum_ = s; - return s; - } - } - - /** - * string seqNum = 11; - */ - public com.google.protobuf.ByteString - getSeqNumBytes() { - Object ref = seqNum_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - seqNum_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getEnvBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, env_); - } - if (!getRegionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, region_); - } - if (!getIdcBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, idc_); - } - if (!getIpBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, ip_); - } - if (!getPidBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 5, pid_); - } - if (!getSysBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 6, sys_); - } - if (!getUsernameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 7, username_); - } - if (!getPasswordBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 8, password_); - } - if (!getVersionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 9, version_); - } - if (!getLanguageBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 10, language_); - } - if (!getSeqNumBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 11, seqNum_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getEnvBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, env_); - } - if (!getRegionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, region_); - } - if (!getIdcBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, idc_); - } - if (!getIpBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, ip_); - } - if (!getPidBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, pid_); - } - if (!getSysBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, sys_); - } - if (!getUsernameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, username_); - } - if (!getPasswordBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, password_); - } - if (!getVersionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, version_); - } - if (!getLanguageBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, language_); - } - if (!getSeqNumBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, seqNum_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof RequestHeader)) { - return super.equals(obj); - } - RequestHeader other = (RequestHeader) obj; - - boolean result = true; - result = result && getEnv() - .equals(other.getEnv()); - result = result && getRegion() - .equals(other.getRegion()); - result = result && getIdc() - .equals(other.getIdc()); - result = result && getIp() - .equals(other.getIp()); - result = result && getPid() - .equals(other.getPid()); - result = result && getSys() - .equals(other.getSys()); - result = result && getUsername() - .equals(other.getUsername()); - result = result && getPassword() - .equals(other.getPassword()); - result = result && getVersion() - .equals(other.getVersion()); - result = result && getLanguage() - .equals(other.getLanguage()); - result = result && getSeqNum() - .equals(other.getSeqNum()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + ENV_FIELD_NUMBER; - hash = (53 * hash) + getEnv().hashCode(); - hash = (37 * hash) + REGION_FIELD_NUMBER; - hash = (53 * hash) + getRegion().hashCode(); - hash = (37 * hash) + IDC_FIELD_NUMBER; - hash = (53 * hash) + getIdc().hashCode(); - hash = (37 * hash) + IP_FIELD_NUMBER; - hash = (53 * hash) + getIp().hashCode(); - hash = (37 * hash) + PID_FIELD_NUMBER; - hash = (53 * hash) + getPid().hashCode(); - hash = (37 * hash) + SYS_FIELD_NUMBER; - hash = (53 * hash) + getSys().hashCode(); - hash = (37 * hash) + USERNAME_FIELD_NUMBER; - hash = (53 * hash) + getUsername().hashCode(); - hash = (37 * hash) + PASSWORD_FIELD_NUMBER; - hash = (53 * hash) + getPassword().hashCode(); - hash = (37 * hash) + VERSION_FIELD_NUMBER; - hash = (53 * hash) + getVersion().hashCode(); - hash = (37 * hash) + LANGUAGE_FIELD_NUMBER; - hash = (53 * hash) + getLanguage().hashCode(); - hash = (37 * hash) + SEQNUM_FIELD_NUMBER; - hash = (53 * hash) + getSeqNum().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static RequestHeader parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static RequestHeader parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static RequestHeader parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static RequestHeader parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static RequestHeader parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static RequestHeader parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static RequestHeader parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static RequestHeader parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static RequestHeader parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static RequestHeader parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static RequestHeader parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static RequestHeader parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(RequestHeader prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.RequestHeader} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.RequestHeader) - RequestHeaderOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_RequestHeader_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_RequestHeader_fieldAccessorTable - .ensureFieldAccessorsInitialized( - RequestHeader.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.RequestHeader.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - public Builder clear() { - super.clear(); - env_ = ""; - - region_ = ""; - - idc_ = ""; - - ip_ = ""; - - pid_ = ""; - - sys_ = ""; - - username_ = ""; - - password_ = ""; - - version_ = ""; - - language_ = ""; - - seqNum_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_RequestHeader_descriptor; - } - - public RequestHeader getDefaultInstanceForType() { - return RequestHeader.getDefaultInstance(); - } - - public RequestHeader build() { - RequestHeader result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public RequestHeader buildPartial() { - RequestHeader result = new RequestHeader(this); - result.env_ = env_; - result.region_ = region_; - result.idc_ = idc_; - result.ip_ = ip_; - result.pid_ = pid_; - result.sys_ = sys_; - result.username_ = username_; - result.password_ = password_; - result.version_ = version_; - result.language_ = language_; - result.seqNum_ = seqNum_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof RequestHeader) { - return mergeFrom((RequestHeader) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(RequestHeader other) { - if (other == RequestHeader.getDefaultInstance()) return this; - if (!other.getEnv().isEmpty()) { - env_ = other.env_; - onChanged(); - } - if (!other.getRegion().isEmpty()) { - region_ = other.region_; - onChanged(); - } - if (!other.getIdc().isEmpty()) { - idc_ = other.idc_; - onChanged(); - } - if (!other.getIp().isEmpty()) { - ip_ = other.ip_; - onChanged(); - } - if (!other.getPid().isEmpty()) { - pid_ = other.pid_; - onChanged(); - } - if (!other.getSys().isEmpty()) { - sys_ = other.sys_; - onChanged(); - } - if (!other.getUsername().isEmpty()) { - username_ = other.username_; - onChanged(); - } - if (!other.getPassword().isEmpty()) { - password_ = other.password_; - onChanged(); - } - if (!other.getVersion().isEmpty()) { - version_ = other.version_; - onChanged(); - } - if (!other.getLanguage().isEmpty()) { - language_ = other.language_; - onChanged(); - } - if (!other.getSeqNum().isEmpty()) { - seqNum_ = other.seqNum_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - RequestHeader parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (RequestHeader) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private Object env_ = ""; - - /** - * string env = 1; - */ - public String getEnv() { - Object ref = env_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - env_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string env = 1; - */ - public com.google.protobuf.ByteString - getEnvBytes() { - Object ref = env_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - env_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string env = 1; - */ - public Builder setEnv( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - env_ = value; - onChanged(); - return this; - } - - /** - * string env = 1; - */ - public Builder clearEnv() { - - env_ = getDefaultInstance().getEnv(); - onChanged(); - return this; - } - - /** - * string env = 1; - */ - public Builder setEnvBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - env_ = value; - onChanged(); - return this; - } - - private Object region_ = ""; - - /** - * string region = 2; - */ - public String getRegion() { - Object ref = region_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - region_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string region = 2; - */ - public com.google.protobuf.ByteString - getRegionBytes() { - Object ref = region_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - region_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string region = 2; - */ - public Builder setRegion( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - region_ = value; - onChanged(); - return this; - } - - /** - * string region = 2; - */ - public Builder clearRegion() { - - region_ = getDefaultInstance().getRegion(); - onChanged(); - return this; - } - - /** - * string region = 2; - */ - public Builder setRegionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - region_ = value; - onChanged(); - return this; - } - - private Object idc_ = ""; - - /** - * string idc = 3; - */ - public String getIdc() { - Object ref = idc_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - idc_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string idc = 3; - */ - public com.google.protobuf.ByteString - getIdcBytes() { - Object ref = idc_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - idc_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string idc = 3; - */ - public Builder setIdc( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - idc_ = value; - onChanged(); - return this; - } - - /** - * string idc = 3; - */ - public Builder clearIdc() { - - idc_ = getDefaultInstance().getIdc(); - onChanged(); - return this; - } - - /** - * string idc = 3; - */ - public Builder setIdcBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - idc_ = value; - onChanged(); - return this; - } - - private Object ip_ = ""; - - /** - * string ip = 4; - */ - public String getIp() { - Object ref = ip_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - ip_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string ip = 4; - */ - public com.google.protobuf.ByteString - getIpBytes() { - Object ref = ip_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - ip_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string ip = 4; - */ - public Builder setIp( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - ip_ = value; - onChanged(); - return this; - } - - /** - * string ip = 4; - */ - public Builder clearIp() { - - ip_ = getDefaultInstance().getIp(); - onChanged(); - return this; - } - - /** - * string ip = 4; - */ - public Builder setIpBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - ip_ = value; - onChanged(); - return this; - } - - private Object pid_ = ""; - - /** - * string pid = 5; - */ - public String getPid() { - Object ref = pid_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - pid_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string pid = 5; - */ - public com.google.protobuf.ByteString - getPidBytes() { - Object ref = pid_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - pid_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string pid = 5; - */ - public Builder setPid( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - pid_ = value; - onChanged(); - return this; - } - - /** - * string pid = 5; - */ - public Builder clearPid() { - - pid_ = getDefaultInstance().getPid(); - onChanged(); - return this; - } - - /** - * string pid = 5; - */ - public Builder setPidBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - pid_ = value; - onChanged(); - return this; - } - - private Object sys_ = ""; - - /** - * string sys = 6; - */ - public String getSys() { - Object ref = sys_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - sys_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string sys = 6; - */ - public com.google.protobuf.ByteString - getSysBytes() { - Object ref = sys_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - sys_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string sys = 6; - */ - public Builder setSys( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - sys_ = value; - onChanged(); - return this; - } - - /** - * string sys = 6; - */ - public Builder clearSys() { - - sys_ = getDefaultInstance().getSys(); - onChanged(); - return this; - } - - /** - * string sys = 6; - */ - public Builder setSysBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - sys_ = value; - onChanged(); - return this; - } - - private Object username_ = ""; - - /** - * string username = 7; - */ - public String getUsername() { - Object ref = username_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - username_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string username = 7; - */ - public com.google.protobuf.ByteString - getUsernameBytes() { - Object ref = username_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - username_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string username = 7; - */ - public Builder setUsername( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - username_ = value; - onChanged(); - return this; - } - - /** - * string username = 7; - */ - public Builder clearUsername() { - - username_ = getDefaultInstance().getUsername(); - onChanged(); - return this; - } - - /** - * string username = 7; - */ - public Builder setUsernameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - username_ = value; - onChanged(); - return this; - } - - private Object password_ = ""; - - /** - * string password = 8; - */ - public String getPassword() { - Object ref = password_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - password_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string password = 8; - */ - public com.google.protobuf.ByteString - getPasswordBytes() { - Object ref = password_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - password_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string password = 8; - */ - public Builder setPassword( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - password_ = value; - onChanged(); - return this; - } - - /** - * string password = 8; - */ - public Builder clearPassword() { - - password_ = getDefaultInstance().getPassword(); - onChanged(); - return this; - } - - /** - * string password = 8; - */ - public Builder setPasswordBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - password_ = value; - onChanged(); - return this; - } - - private Object version_ = ""; - - /** - * string version = 9; - */ - public String getVersion() { - Object ref = version_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - version_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string version = 9; - */ - public com.google.protobuf.ByteString - getVersionBytes() { - Object ref = version_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - version_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string version = 9; - */ - public Builder setVersion( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - version_ = value; - onChanged(); - return this; - } - - /** - * string version = 9; - */ - public Builder clearVersion() { - - version_ = getDefaultInstance().getVersion(); - onChanged(); - return this; - } - - /** - * string version = 9; - */ - public Builder setVersionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - version_ = value; - onChanged(); - return this; - } - - private Object language_ = ""; - - /** - * string language = 10; - */ - public String getLanguage() { - Object ref = language_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - language_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string language = 10; - */ - public com.google.protobuf.ByteString - getLanguageBytes() { - Object ref = language_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - language_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string language = 10; - */ - public Builder setLanguage( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - language_ = value; - onChanged(); - return this; - } - - /** - * string language = 10; - */ - public Builder clearLanguage() { - - language_ = getDefaultInstance().getLanguage(); - onChanged(); - return this; - } - - /** - * string language = 10; - */ - public Builder setLanguageBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - language_ = value; - onChanged(); - return this; - } - - private Object seqNum_ = ""; - - /** - * string seqNum = 11; - */ - public String getSeqNum() { - Object ref = seqNum_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - seqNum_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string seqNum = 11; - */ - public com.google.protobuf.ByteString - getSeqNumBytes() { - Object ref = seqNum_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - seqNum_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string seqNum = 11; - */ - public Builder setSeqNum( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - seqNum_ = value; - onChanged(); - return this; - } - - /** - * string seqNum = 11; - */ - public Builder clearSeqNum() { - - seqNum_ = getDefaultInstance().getSeqNum(); - onChanged(); - return this; - } - - /** - * string seqNum = 11; - */ - public Builder setSeqNumBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - seqNum_ = value; - onChanged(); - return this; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.RequestHeader) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.RequestHeader) - private static final RequestHeader DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new RequestHeader(); - } - - public static RequestHeader getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public RequestHeader parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new RequestHeader(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public RequestHeader getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeaderOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeaderOrBuilder.java deleted file mode 100644 index a112bfa22a..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeaderOrBuilder.java +++ /dev/null @@ -1,137 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * RequestHeaderOrBuilder interface. - */ -public interface RequestHeaderOrBuilder extends com.google.protobuf.MessageOrBuilder { - - /** - * string env = 1. - */ - String getEnv(); - - /** - * string env = 1. - */ - com.google.protobuf.ByteString getEnvBytes(); - - /** - * string region = 2. - */ - String getRegion(); - - /** - * string region = 2. - */ - com.google.protobuf.ByteString getRegionBytes(); - - /** - * string idc = 3. - */ - String getIdc(); - - /** - * string idc = 3. - */ - com.google.protobuf.ByteString getIdcBytes(); - - /** - * string ip = 4. - */ - String getIp(); - - /** - * string ip = 4. - */ - com.google.protobuf.ByteString getIpBytes(); - - /** - * string pid = 5. - */ - String getPid(); - - /** - * string pid = 5. - */ - com.google.protobuf.ByteString getPidBytes(); - - /** - * string sys = 6. - */ - String getSys(); - - /** - * string sys = 6. - */ - com.google.protobuf.ByteString getSysBytes(); - - /** - * string username = 7. - */ - String getUsername(); - - /** - * string username = 7. - */ - com.google.protobuf.ByteString getUsernameBytes(); - - /** - * string password = 8. - */ - String getPassword(); - - /** - * string password = 8. - */ - com.google.protobuf.ByteString getPasswordBytes(); - - /** - * string version = 9. - */ - String getVersion(); - - /** - * string version = 9. - */ - com.google.protobuf.ByteString getVersionBytes(); - - /** - * string language = 10. - */ - String getLanguage(); - - /** - * string language = 10. - */ - com.google.protobuf.ByteString getLanguageBytes(); - - /** - * string seqNum = 11. - */ - String getSeqNum(); - - /** - * string seqNum = 11. - */ - com.google.protobuf.ByteString getSeqNumBytes(); -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Response.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Response.java deleted file mode 100644 index b54fc330c8..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Response.java +++ /dev/null @@ -1,972 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * Protobuf type {@code eventmesh.client.Response} - */ -public final class Response extends - com.google.protobuf.GeneratedMessageV3 implements ResponseOrBuilder { - private static final long serialVersionUID = 0L; - - // Use Response.newBuilder() to construct. - private Response(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private Response() { - respCode_ = ""; - respMsg_ = ""; - respTime_ = ""; - seqNum_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private Response( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - respCode_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - respMsg_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - respTime_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - seqNum_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Response_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Response_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Response.class, Builder.class); - } - - public static final int RESPCODE_FIELD_NUMBER = 1; - private volatile Object respCode_; - - /** - * string respCode = 1; - */ - public String getRespCode() { - Object ref = respCode_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - respCode_ = s; - return s; - } - } - - /** - * string respCode = 1; - */ - public com.google.protobuf.ByteString - getRespCodeBytes() { - Object ref = respCode_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - respCode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int RESPMSG_FIELD_NUMBER = 2; - private volatile Object respMsg_; - - /** - * string respMsg = 2; - */ - public String getRespMsg() { - Object ref = respMsg_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - respMsg_ = s; - return s; - } - } - - /** - * string respMsg = 2; - */ - public com.google.protobuf.ByteString - getRespMsgBytes() { - Object ref = respMsg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - respMsg_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int RESPTIME_FIELD_NUMBER = 3; - private volatile Object respTime_; - - /** - * string respTime = 3; - */ - public String getRespTime() { - Object ref = respTime_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - respTime_ = s; - return s; - } - } - - /** - * string respTime = 3; - */ - public com.google.protobuf.ByteString - getRespTimeBytes() { - Object ref = respTime_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - respTime_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SEQNUM_FIELD_NUMBER = 4; - private volatile Object seqNum_; - - /** - * string seqNum = 4; - */ - public String getSeqNum() { - Object ref = seqNum_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - seqNum_ = s; - return s; - } - } - - /** - * string seqNum = 4; - */ - public com.google.protobuf.ByteString - getSeqNumBytes() { - Object ref = seqNum_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - seqNum_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getRespCodeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, respCode_); - } - if (!getRespMsgBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, respMsg_); - } - if (!getRespTimeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, respTime_); - } - if (!getSeqNumBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, seqNum_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getRespCodeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, respCode_); - } - if (!getRespMsgBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, respMsg_); - } - if (!getRespTimeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, respTime_); - } - if (!getSeqNumBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, seqNum_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Response)) { - return super.equals(obj); - } - Response other = (Response) obj; - - boolean result = true; - result = result && getRespCode() - .equals(other.getRespCode()); - result = result && getRespMsg() - .equals(other.getRespMsg()); - result = result && getRespTime() - .equals(other.getRespTime()); - result = result && getSeqNum() - .equals(other.getSeqNum()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + RESPCODE_FIELD_NUMBER; - hash = (53 * hash) + getRespCode().hashCode(); - hash = (37 * hash) + RESPMSG_FIELD_NUMBER; - hash = (53 * hash) + getRespMsg().hashCode(); - hash = (37 * hash) + RESPTIME_FIELD_NUMBER; - hash = (53 * hash) + getRespTime().hashCode(); - hash = (37 * hash) + SEQNUM_FIELD_NUMBER; - hash = (53 * hash) + getSeqNum().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static Response parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Response parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Response parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Response parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Response parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Response parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Response parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Response parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static Response parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static Response parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static Response parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Response parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(Response prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.Response} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.Response) - ResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Response_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Response_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Response.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.Response.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - public Builder clear() { - super.clear(); - respCode_ = ""; - - respMsg_ = ""; - - respTime_ = ""; - - seqNum_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_Response_descriptor; - } - - public Response getDefaultInstanceForType() { - return Response.getDefaultInstance(); - } - - public Response build() { - Response result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Response buildPartial() { - Response result = new Response(this); - result.respCode_ = respCode_; - result.respMsg_ = respMsg_; - result.respTime_ = respTime_; - result.seqNum_ = seqNum_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Response) { - return mergeFrom((Response) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(Response other) { - if (other == Response.getDefaultInstance()) return this; - if (!other.getRespCode().isEmpty()) { - respCode_ = other.respCode_; - onChanged(); - } - if (!other.getRespMsg().isEmpty()) { - respMsg_ = other.respMsg_; - onChanged(); - } - if (!other.getRespTime().isEmpty()) { - respTime_ = other.respTime_; - onChanged(); - } - if (!other.getSeqNum().isEmpty()) { - seqNum_ = other.seqNum_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Response parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Response) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private Object respCode_ = ""; - - /** - * string respCode = 1; - */ - public String getRespCode() { - Object ref = respCode_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - respCode_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string respCode = 1; - */ - public com.google.protobuf.ByteString - getRespCodeBytes() { - Object ref = respCode_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - respCode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string respCode = 1; - */ - public Builder setRespCode( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - respCode_ = value; - onChanged(); - return this; - } - - /** - * string respCode = 1; - */ - public Builder clearRespCode() { - - respCode_ = getDefaultInstance().getRespCode(); - onChanged(); - return this; - } - - /** - * string respCode = 1; - */ - public Builder setRespCodeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - respCode_ = value; - onChanged(); - return this; - } - - private Object respMsg_ = ""; - - /** - * string respMsg = 2; - */ - public String getRespMsg() { - Object ref = respMsg_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - respMsg_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string respMsg = 2; - */ - public com.google.protobuf.ByteString - getRespMsgBytes() { - Object ref = respMsg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - respMsg_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string respMsg = 2; - */ - public Builder setRespMsg( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - respMsg_ = value; - onChanged(); - return this; - } - - /** - * string respMsg = 2; - */ - public Builder clearRespMsg() { - - respMsg_ = getDefaultInstance().getRespMsg(); - onChanged(); - return this; - } - - /** - * string respMsg = 2; - */ - public Builder setRespMsgBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - respMsg_ = value; - onChanged(); - return this; - } - - private Object respTime_ = ""; - - /** - * string respTime = 3; - */ - public String getRespTime() { - Object ref = respTime_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - respTime_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string respTime = 3; - */ - public com.google.protobuf.ByteString - getRespTimeBytes() { - Object ref = respTime_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - respTime_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string respTime = 3; - */ - public Builder setRespTime( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - respTime_ = value; - onChanged(); - return this; - } - - /** - * string respTime = 3; - */ - public Builder clearRespTime() { - - respTime_ = getDefaultInstance().getRespTime(); - onChanged(); - return this; - } - - /** - * string respTime = 3; - */ - public Builder setRespTimeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - respTime_ = value; - onChanged(); - return this; - } - - private Object seqNum_ = ""; - - /** - * string seqNum = 4; - */ - public String getSeqNum() { - Object ref = seqNum_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - seqNum_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string seqNum = 4; - */ - public com.google.protobuf.ByteString - getSeqNumBytes() { - Object ref = seqNum_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - seqNum_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string seqNum = 4; - */ - public Builder setSeqNum( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - seqNum_ = value; - onChanged(); - return this; - } - - /** - * string seqNum = 4; - */ - public Builder clearSeqNum() { - - seqNum_ = getDefaultInstance().getSeqNum(); - onChanged(); - return this; - } - - /** - * string seqNum = 4; - */ - public Builder setSeqNumBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - seqNum_ = value; - onChanged(); - return this; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.Response) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.Response) - private static final Response DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new Response(); - } - - public static Response getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Response parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Response(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public Response getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ResponseOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ResponseOrBuilder.java deleted file mode 100644 index 0b4acd2fe4..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ResponseOrBuilder.java +++ /dev/null @@ -1,67 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * ResponseOrBuilder interface. - */ -public interface ResponseOrBuilder extends com.google.protobuf.MessageOrBuilder { - - /** - * string respCode = 1. - */ - String getRespCode(); - - /** - * string respCode = 1. - */ - com.google.protobuf.ByteString getRespCodeBytes(); - - /** - * string respMsg = 2. - */ - String getRespMsg(); - - /** - * string respMsg = 2. - */ - com.google.protobuf.ByteString getRespMsgBytes(); - - /** - * string respTime = 3. - */ - String getRespTime(); - - /** - * string respTime = 3. - */ - com.google.protobuf.ByteString getRespTimeBytes(); - - /** - * string seqNum = 4. - */ - String getSeqNum(); - - /** - * string seqNum = 4. - */ - com.google.protobuf.ByteString getSeqNumBytes(); -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Subscription.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Subscription.java deleted file mode 100644 index 803e1daf5c..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Subscription.java +++ /dev/null @@ -1,2138 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * Protobuf type {@code eventmesh.client.Subscription} - */ -public final class Subscription extends - com.google.protobuf.GeneratedMessageV3 implements SubscriptionOrBuilder { - private static final long serialVersionUID = 0L; - - // Use Subscription.newBuilder() to construct. - private Subscription(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private Subscription() { - consumerGroup_ = ""; - subscriptionItems_ = java.util.Collections.emptyList(); - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private Subscription( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - RequestHeader.Builder subBuilder = null; - if (header_ != null) { - subBuilder = header_.toBuilder(); - } - header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(header_); - header_ = subBuilder.buildPartial(); - } - - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - consumerGroup_ = s; - break; - } - case 26: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - subscriptionItems_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - subscriptionItems_.add( - input.readMessage(SubscriptionItem.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - subscriptionItems_ = java.util.Collections.unmodifiableList(subscriptionItems_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Subscription.class, Builder.class); - } - - public interface SubscriptionItemOrBuilder extends - // @@protoc_insertion_point(interface_extends:eventmesh.client.Subscription.SubscriptionItem) - com.google.protobuf.MessageOrBuilder { - - /** - * string topic = 1; - */ - String getTopic(); - - /** - * string topic = 1; - */ - com.google.protobuf.ByteString - getTopicBytes(); - - /** - * string mode = 2; - */ - String getMode(); - - /** - * string mode = 2; - */ - com.google.protobuf.ByteString - getModeBytes(); - - /** - * string type = 3; - */ - String getType(); - - /** - * string type = 3; - */ - com.google.protobuf.ByteString - getTypeBytes(); - - /** - * string url = 4; - */ - String getUrl(); - - /** - * string url = 4; - */ - com.google.protobuf.ByteString - getUrlBytes(); - } - - /** - * Protobuf type {@code eventmesh.client.Subscription.SubscriptionItem} - */ - public static final class SubscriptionItem extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:eventmesh.client.Subscription.SubscriptionItem) - SubscriptionItemOrBuilder { - private static final long serialVersionUID = 0L; - - // Use SubscriptionItem.newBuilder() to construct. - private SubscriptionItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private SubscriptionItem() { - topic_ = ""; - mode_ = ""; - type_ = ""; - url_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private SubscriptionItem( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - topic_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - mode_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - type_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - url_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SubscriptionItem.class, Builder.class); - } - - public static final int TOPIC_FIELD_NUMBER = 1; - private volatile Object topic_; - - /** - * string topic = 1; - */ - public String getTopic() { - Object ref = topic_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - topic_ = s; - return s; - } - } - - /** - * string topic = 1; - */ - public com.google.protobuf.ByteString - getTopicBytes() { - Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int MODE_FIELD_NUMBER = 2; - private volatile Object mode_; - - /** - * string mode = 2; - */ - public String getMode() { - Object ref = mode_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - mode_ = s; - return s; - } - } - - /** - * string mode = 2; - */ - public com.google.protobuf.ByteString - getModeBytes() { - Object ref = mode_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - mode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TYPE_FIELD_NUMBER = 3; - private volatile Object type_; - - /** - * string type = 3; - */ - public String getType() { - Object ref = type_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - type_ = s; - return s; - } - } - - /** - * string type = 3; - */ - public com.google.protobuf.ByteString - getTypeBytes() { - Object ref = type_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - type_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int URL_FIELD_NUMBER = 4; - private volatile Object url_; - - /** - * string url = 4; - */ - public String getUrl() { - Object ref = url_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - url_ = s; - return s; - } - } - - /** - * string url = 4; - */ - public com.google.protobuf.ByteString - getUrlBytes() { - Object ref = url_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - url_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getTopicBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); - } - if (!getModeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, mode_); - } - if (!getTypeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, type_); - } - if (!getUrlBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, url_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getTopicBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); - } - if (!getModeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, mode_); - } - if (!getTypeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, type_); - } - if (!getUrlBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, url_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SubscriptionItem)) { - return super.equals(obj); - } - SubscriptionItem other = (SubscriptionItem) obj; - - boolean result = true; - result = result && getTopic() - .equals(other.getTopic()); - result = result && getMode() - .equals(other.getMode()); - result = result && getType() - .equals(other.getType()); - result = result && getUrl() - .equals(other.getUrl()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + TOPIC_FIELD_NUMBER; - hash = (53 * hash) + getTopic().hashCode(); - hash = (37 * hash) + MODE_FIELD_NUMBER; - hash = (53 * hash) + getMode().hashCode(); - hash = (37 * hash) + TYPE_FIELD_NUMBER; - hash = (53 * hash) + getType().hashCode(); - hash = (37 * hash) + URL_FIELD_NUMBER; - hash = (53 * hash) + getUrl().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static SubscriptionItem parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static SubscriptionItem parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static SubscriptionItem parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static SubscriptionItem parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static SubscriptionItem parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static SubscriptionItem parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static SubscriptionItem parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static SubscriptionItem parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static SubscriptionItem parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static SubscriptionItem parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static SubscriptionItem parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static SubscriptionItem parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(SubscriptionItem prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.Subscription.SubscriptionItem} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.Subscription.SubscriptionItem) - SubscriptionItemOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SubscriptionItem.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.Subscription.SubscriptionItem.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - public Builder clear() { - super.clear(); - topic_ = ""; - - mode_ = ""; - - type_ = ""; - - url_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor; - } - - public SubscriptionItem getDefaultInstanceForType() { - return SubscriptionItem.getDefaultInstance(); - } - - public SubscriptionItem build() { - SubscriptionItem result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public SubscriptionItem buildPartial() { - SubscriptionItem result = new SubscriptionItem(this); - result.topic_ = topic_; - result.mode_ = mode_; - result.type_ = type_; - result.url_ = url_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SubscriptionItem) { - return mergeFrom((SubscriptionItem) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(SubscriptionItem other) { - if (other == SubscriptionItem.getDefaultInstance()) return this; - if (!other.getTopic().isEmpty()) { - topic_ = other.topic_; - onChanged(); - } - if (!other.getMode().isEmpty()) { - mode_ = other.mode_; - onChanged(); - } - if (!other.getType().isEmpty()) { - type_ = other.type_; - onChanged(); - } - if (!other.getUrl().isEmpty()) { - url_ = other.url_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - SubscriptionItem parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (SubscriptionItem) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private Object topic_ = ""; - - /** - * string topic = 1; - */ - public String getTopic() { - Object ref = topic_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - topic_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string topic = 1; - */ - public com.google.protobuf.ByteString - getTopicBytes() { - Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string topic = 1; - */ - public Builder setTopic( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - topic_ = value; - onChanged(); - return this; - } - - /** - * string topic = 1; - */ - public Builder clearTopic() { - - topic_ = getDefaultInstance().getTopic(); - onChanged(); - return this; - } - - /** - * string topic = 1; - */ - public Builder setTopicBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - topic_ = value; - onChanged(); - return this; - } - - private Object mode_ = ""; - - /** - * string mode = 2; - */ - public String getMode() { - Object ref = mode_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - mode_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string mode = 2; - */ - public com.google.protobuf.ByteString - getModeBytes() { - Object ref = mode_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - mode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string mode = 2; - */ - public Builder setMode( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - mode_ = value; - onChanged(); - return this; - } - - /** - * string mode = 2; - */ - public Builder clearMode() { - - mode_ = getDefaultInstance().getMode(); - onChanged(); - return this; - } - - /** - * string mode = 2; - */ - public Builder setModeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - mode_ = value; - onChanged(); - return this; - } - - private Object type_ = ""; - - /** - * string type = 3; - */ - public String getType() { - Object ref = type_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - type_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string type = 3; - */ - public com.google.protobuf.ByteString - getTypeBytes() { - Object ref = type_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - type_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string type = 3; - */ - public Builder setType( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - type_ = value; - onChanged(); - return this; - } - - /** - * string type = 3; - */ - public Builder clearType() { - - type_ = getDefaultInstance().getType(); - onChanged(); - return this; - } - - /** - * string type = 3; - */ - public Builder setTypeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - type_ = value; - onChanged(); - return this; - } - - private Object url_ = ""; - - /** - * string url = 4; - */ - public String getUrl() { - Object ref = url_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - url_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string url = 4; - */ - public com.google.protobuf.ByteString - getUrlBytes() { - Object ref = url_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - url_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string url = 4; - */ - public Builder setUrl( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - url_ = value; - onChanged(); - return this; - } - - /** - * string url = 4; - */ - public Builder clearUrl() { - - url_ = getDefaultInstance().getUrl(); - onChanged(); - return this; - } - - /** - * string url = 4; - */ - public Builder setUrlBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - url_ = value; - onChanged(); - return this; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.Subscription.SubscriptionItem) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.Subscription.SubscriptionItem) - private static final SubscriptionItem DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new SubscriptionItem(); - } - - public static SubscriptionItem getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public SubscriptionItem parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new SubscriptionItem(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public SubscriptionItem getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private int bitField0_; - public static final int HEADER_FIELD_NUMBER = 1; - private RequestHeader header_; - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public boolean hasHeader() { - return header_ != null; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader getHeader() { - return header_ == null ? RequestHeader.getDefaultInstance() : header_; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeaderOrBuilder getHeaderOrBuilder() { - return getHeader(); - } - - public static final int CONSUMERGROUP_FIELD_NUMBER = 2; - private volatile Object consumerGroup_; - - /** - * string consumerGroup = 2; - */ - public String getConsumerGroup() { - Object ref = consumerGroup_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - consumerGroup_ = s; - return s; - } - } - - /** - * string consumerGroup = 2; - */ - public com.google.protobuf.ByteString - getConsumerGroupBytes() { - Object ref = consumerGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - consumerGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SUBSCRIPTIONITEMS_FIELD_NUMBER = 3; - private java.util.List subscriptionItems_; - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public java.util.List getSubscriptionItemsList() { - return subscriptionItems_; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public java.util.List - getSubscriptionItemsOrBuilderList() { - return subscriptionItems_; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public int getSubscriptionItemsCount() { - return subscriptionItems_.size(); - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItem getSubscriptionItems(int index) { - return subscriptionItems_.get(index); - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( - int index) { - return subscriptionItems_.get(index); - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (header_ != null) { - output.writeMessage(1, getHeader()); - } - if (!getConsumerGroupBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, consumerGroup_); - } - for (int i = 0; i < subscriptionItems_.size(); i++) { - output.writeMessage(3, subscriptionItems_.get(i)); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (header_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getHeader()); - } - if (!getConsumerGroupBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, consumerGroup_); - } - for (int i = 0; i < subscriptionItems_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, subscriptionItems_.get(i)); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Subscription)) { - return super.equals(obj); - } - Subscription other = (Subscription) obj; - - boolean result = true; - result = result && (hasHeader() == other.hasHeader()); - if (hasHeader()) { - result = result && getHeader() - .equals(other.getHeader()); - } - result = result && getConsumerGroup() - .equals(other.getConsumerGroup()); - result = result && getSubscriptionItemsList() - .equals(other.getSubscriptionItemsList()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasHeader()) { - hash = (37 * hash) + HEADER_FIELD_NUMBER; - hash = (53 * hash) + getHeader().hashCode(); - } - hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER; - hash = (53 * hash) + getConsumerGroup().hashCode(); - if (getSubscriptionItemsCount() > 0) { - hash = (37 * hash) + SUBSCRIPTIONITEMS_FIELD_NUMBER; - hash = (53 * hash) + getSubscriptionItemsList().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static Subscription parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Subscription parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Subscription parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Subscription parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Subscription parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Subscription parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Subscription parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Subscription parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static Subscription parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static Subscription parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static Subscription parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Subscription parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(Subscription prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.Subscription} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.Subscription) - SubscriptionOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Subscription.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.Subscription.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - getSubscriptionItemsFieldBuilder(); - } - } - - public Builder clear() { - super.clear(); - if (headerBuilder_ == null) { - header_ = null; - } else { - header_ = null; - headerBuilder_ = null; - } - consumerGroup_ = ""; - - if (subscriptionItemsBuilder_ == null) { - subscriptionItems_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - } else { - subscriptionItemsBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_descriptor; - } - - public Subscription getDefaultInstanceForType() { - return Subscription.getDefaultInstance(); - } - - public Subscription build() { - Subscription result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Subscription buildPartial() { - Subscription result = new Subscription(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (headerBuilder_ == null) { - result.header_ = header_; - } else { - result.header_ = headerBuilder_.build(); - } - result.consumerGroup_ = consumerGroup_; - if (subscriptionItemsBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004)) { - subscriptionItems_ = java.util.Collections.unmodifiableList(subscriptionItems_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.subscriptionItems_ = subscriptionItems_; - } else { - result.subscriptionItems_ = subscriptionItemsBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Subscription) { - return mergeFrom((Subscription) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(Subscription other) { - if (other == Subscription.getDefaultInstance()) return this; - if (other.hasHeader()) { - mergeHeader(other.getHeader()); - } - if (!other.getConsumerGroup().isEmpty()) { - consumerGroup_ = other.consumerGroup_; - onChanged(); - } - if (subscriptionItemsBuilder_ == null) { - if (!other.subscriptionItems_.isEmpty()) { - if (subscriptionItems_.isEmpty()) { - subscriptionItems_ = other.subscriptionItems_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.addAll(other.subscriptionItems_); - } - onChanged(); - } - } else { - if (!other.subscriptionItems_.isEmpty()) { - if (subscriptionItemsBuilder_.isEmpty()) { - subscriptionItemsBuilder_.dispose(); - subscriptionItemsBuilder_ = null; - subscriptionItems_ = other.subscriptionItems_; - bitField0_ = (bitField0_ & ~0x00000004); - subscriptionItemsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getSubscriptionItemsFieldBuilder() : null; - } else { - subscriptionItemsBuilder_.addAllMessages(other.subscriptionItems_); - } - } - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Subscription parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Subscription) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int bitField0_; - - private RequestHeader header_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public boolean hasHeader() { - return headerBuilder_ != null || header_ != null; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader getHeader() { - if (headerBuilder_ == null) { - return header_ == null ? RequestHeader.getDefaultInstance() : header_; - } else { - return headerBuilder_.getMessage(); - } - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder setHeader(RequestHeader value) { - if (headerBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - header_ = value; - onChanged(); - } else { - headerBuilder_.setMessage(value); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder setHeader( - RequestHeader.Builder builderForValue) { - if (headerBuilder_ == null) { - header_ = builderForValue.build(); - onChanged(); - } else { - headerBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder mergeHeader(RequestHeader value) { - if (headerBuilder_ == null) { - if (header_ != null) { - header_ = - RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); - } else { - header_ = value; - } - onChanged(); - } else { - headerBuilder_.mergeFrom(value); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder clearHeader() { - if (headerBuilder_ == null) { - header_ = null; - onChanged(); - } else { - header_ = null; - headerBuilder_ = null; - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader.Builder getHeaderBuilder() { - - onChanged(); - return getHeaderFieldBuilder().getBuilder(); - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeaderOrBuilder getHeaderOrBuilder() { - if (headerBuilder_ != null) { - return headerBuilder_.getMessageOrBuilder(); - } else { - return header_ == null ? - RequestHeader.getDefaultInstance() : header_; - } - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> - getHeaderFieldBuilder() { - if (headerBuilder_ == null) { - headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( - getHeader(), - getParentForChildren(), - isClean()); - header_ = null; - } - return headerBuilder_; - } - - private Object consumerGroup_ = ""; - - /** - * string consumerGroup = 2; - */ - public String getConsumerGroup() { - Object ref = consumerGroup_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - consumerGroup_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string consumerGroup = 2; - */ - public com.google.protobuf.ByteString - getConsumerGroupBytes() { - Object ref = consumerGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - consumerGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string consumerGroup = 2; - */ - public Builder setConsumerGroup( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - consumerGroup_ = value; - onChanged(); - return this; - } - - /** - * string consumerGroup = 2; - */ - public Builder clearConsumerGroup() { - - consumerGroup_ = getDefaultInstance().getConsumerGroup(); - onChanged(); - return this; - } - - /** - * string consumerGroup = 2; - */ - public Builder setConsumerGroupBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - consumerGroup_ = value; - onChanged(); - return this; - } - - private java.util.List subscriptionItems_ = - java.util.Collections.emptyList(); - - private void ensureSubscriptionItemsIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - subscriptionItems_ = new java.util.ArrayList(subscriptionItems_); - bitField0_ |= 0x00000004; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder> subscriptionItemsBuilder_; - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public java.util.List getSubscriptionItemsList() { - if (subscriptionItemsBuilder_ == null) { - return java.util.Collections.unmodifiableList(subscriptionItems_); - } else { - return subscriptionItemsBuilder_.getMessageList(); - } - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public int getSubscriptionItemsCount() { - if (subscriptionItemsBuilder_ == null) { - return subscriptionItems_.size(); - } else { - return subscriptionItemsBuilder_.getCount(); - } - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItem getSubscriptionItems(int index) { - if (subscriptionItemsBuilder_ == null) { - return subscriptionItems_.get(index); - } else { - return subscriptionItemsBuilder_.getMessage(index); - } - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder setSubscriptionItems( - int index, SubscriptionItem value) { - if (subscriptionItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.set(index, value); - onChanged(); - } else { - subscriptionItemsBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder setSubscriptionItems( - int index, SubscriptionItem.Builder builderForValue) { - if (subscriptionItemsBuilder_ == null) { - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.set(index, builderForValue.build()); - onChanged(); - } else { - subscriptionItemsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder addSubscriptionItems(SubscriptionItem value) { - if (subscriptionItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.add(value); - onChanged(); - } else { - subscriptionItemsBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder addSubscriptionItems( - int index, SubscriptionItem value) { - if (subscriptionItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.add(index, value); - onChanged(); - } else { - subscriptionItemsBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder addSubscriptionItems( - SubscriptionItem.Builder builderForValue) { - if (subscriptionItemsBuilder_ == null) { - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.add(builderForValue.build()); - onChanged(); - } else { - subscriptionItemsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder addSubscriptionItems( - int index, SubscriptionItem.Builder builderForValue) { - if (subscriptionItemsBuilder_ == null) { - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.add(index, builderForValue.build()); - onChanged(); - } else { - subscriptionItemsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder addAllSubscriptionItems( - Iterable values) { - if (subscriptionItemsBuilder_ == null) { - ensureSubscriptionItemsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, subscriptionItems_); - onChanged(); - } else { - subscriptionItemsBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder clearSubscriptionItems() { - if (subscriptionItemsBuilder_ == null) { - subscriptionItems_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - } else { - subscriptionItemsBuilder_.clear(); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder removeSubscriptionItems(int index) { - if (subscriptionItemsBuilder_ == null) { - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.remove(index); - onChanged(); - } else { - subscriptionItemsBuilder_.remove(index); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItem.Builder getSubscriptionItemsBuilder( - int index) { - return getSubscriptionItemsFieldBuilder().getBuilder(index); - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( - int index) { - if (subscriptionItemsBuilder_ == null) { - return subscriptionItems_.get(index); - } else { - return subscriptionItemsBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public java.util.List - getSubscriptionItemsOrBuilderList() { - if (subscriptionItemsBuilder_ != null) { - return subscriptionItemsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(subscriptionItems_); - } - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItem.Builder addSubscriptionItemsBuilder() { - return getSubscriptionItemsFieldBuilder().addBuilder( - SubscriptionItem.getDefaultInstance()); - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItem.Builder addSubscriptionItemsBuilder( - int index) { - return getSubscriptionItemsFieldBuilder().addBuilder( - index, SubscriptionItem.getDefaultInstance()); - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public java.util.List - getSubscriptionItemsBuilderList() { - return getSubscriptionItemsFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder> - getSubscriptionItemsFieldBuilder() { - if (subscriptionItemsBuilder_ == null) { - subscriptionItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder>( - subscriptionItems_, - ((bitField0_ & 0x00000004) == 0x00000004), - getParentForChildren(), - isClean()); - subscriptionItems_ = null; - } - return subscriptionItemsBuilder_; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.Subscription) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.Subscription) - private static final Subscription DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new Subscription(); - } - - public static Subscription getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Subscription parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Subscription(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public Subscription getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/SubscriptionOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/SubscriptionOrBuilder.java deleted file mode 100644 index b47e54826d..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/SubscriptionOrBuilder.java +++ /dev/null @@ -1,78 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * SubscriptionOrBuilder interface. - */ -public interface SubscriptionOrBuilder extends com.google.protobuf.MessageOrBuilder { - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - boolean hasHeader(); - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - RequestHeader getHeader(); - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - RequestHeaderOrBuilder getHeaderOrBuilder(); - - /** - * string consumerGroup = 2. - */ - String getConsumerGroup(); - - /** - * string consumerGroup = 2. - */ - com.google.protobuf.ByteString getConsumerGroupBytes(); - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. - */ - java.util.List getSubscriptionItemsList(); - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. - */ - Subscription.SubscriptionItem getSubscriptionItems(int index); - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. - */ - int getSubscriptionItemsCount(); - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. - */ - java.util.List - getSubscriptionItemsOrBuilderList(); - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. - */ - Subscription.SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder(int index); -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java new file mode 100644 index 0000000000..5cb2907f88 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java @@ -0,0 +1,29 @@ +package org.apache.eventmesh.client.grpc.util; + +import io.cloudevents.SpecVersion; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; + +public class EventMeshClientUtil { + + private final static String PROTOCOL_TYPE = "eventmeshmessage"; + private final static String PROTOCOL_DESC = "grpc"; + + public static RequestHeader buildHeader(EventMeshGrpcClientConfig clientConfig) { + RequestHeader header = RequestHeader.newBuilder() + .setEnv(clientConfig.getEnv()) + .setIdc(clientConfig.getIdc()) + .setIp(clientConfig.getIp()) + .setPid(clientConfig.getPid()) + .setSys(clientConfig.getSys()) + .setLanguage(clientConfig.getLanguage()) + .setUsername(clientConfig.getUserName()) + .setPassword(clientConfig.getPassword()) + .setProtocolType(PROTOCOL_TYPE) + .setProtocolDesc(PROTOCOL_DESC) + // default CloudEvents version is V1 + .setProtocolVersion(SpecVersion.V1.toString()) + .build(); + return header; + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/AbstractHttpClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/AbstractHttpClient.java new file mode 100644 index 0000000000..bb415248a4 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/AbstractHttpClient.java @@ -0,0 +1,98 @@ +/* + * Licensed 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.eventmesh.client.http; + +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.ssl.MyX509TrustManager; +import org.apache.eventmesh.client.http.util.HttpLoadBalanceUtils; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.loadbalance.LoadBalanceSelector; + +import org.apache.http.conn.ssl.DefaultHostnameVerifier; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; + +import java.io.IOException; +import java.security.SecureRandom; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; + +import com.google.common.base.Preconditions; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public abstract class AbstractHttpClient implements AutoCloseable { + + protected EventMeshHttpClientConfig eventMeshHttpClientConfig; + + protected LoadBalanceSelector eventMeshServerSelector; + + protected final CloseableHttpClient httpClient; + + public AbstractHttpClient(EventMeshHttpClientConfig eventMeshHttpClientConfig) throws EventMeshException { + Preconditions.checkNotNull(eventMeshHttpClientConfig, "liteClientConfig can't be null"); + Preconditions.checkNotNull(eventMeshHttpClientConfig.getLiteEventMeshAddr(), "liteServerAddr can't be null"); + + this.eventMeshHttpClientConfig = eventMeshHttpClientConfig; + this.eventMeshServerSelector = HttpLoadBalanceUtils.createEventMeshServerLoadBalanceSelector( + eventMeshHttpClientConfig); + this.httpClient = setHttpClient(); + } + + public void close() throws EventMeshException { + try (final CloseableHttpClient ignore = this.httpClient) { + // ignore + } catch (IOException e) { + throw new EventMeshException("Close http client error", e); + } + } + + private CloseableHttpClient setHttpClient() throws EventMeshException { + if (!eventMeshHttpClientConfig.isUseTls()) { + return HttpClients.createDefault(); + } + SSLContext sslContext; + try { + // todo: config in properties file? + String protocol = System.getProperty("ssl.client.protocol", "TLSv1.2"); + TrustManager[] tm = new TrustManager[] {new MyX509TrustManager()}; + sslContext = SSLContext.getInstance(protocol); + sslContext.init(null, tm, new SecureRandom()); + // todo: custom client pool + return HttpClients.custom() + .setSSLContext(sslContext) + .setSSLHostnameVerifier(new DefaultHostnameVerifier()) + .build(); + } catch (Exception e) { + log.error("Error in creating HttpClient.", e); + throw new EventMeshException(e); + } + } + + protected String selectEventMesh() { + // todo: target endpoint maybe destroy, should remove the bad endpoint + if (eventMeshHttpClientConfig.isUseTls()) { + return Constants.HTTPS_PROTOCOL_PREFIX + eventMeshServerSelector.select(); + } else { + return Constants.HTTP_PROTOCOL_PREFIX + eventMeshServerSelector.select(); + } + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/AbstractLiteClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/AbstractLiteClient.java deleted file mode 100644 index 20302af8e6..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/AbstractLiteClient.java +++ /dev/null @@ -1,74 +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 org.apache.eventmesh.client.http; - -import org.apache.eventmesh.client.http.conf.LiteClientConfig; -import org.apache.eventmesh.client.http.ssl.MyX509TrustManager; -import org.apache.eventmesh.client.http.util.HttpLoadBalanceUtils; -import org.apache.eventmesh.common.loadbalance.LoadBalanceSelector; -import org.apache.http.conn.ssl.DefaultHostnameVerifier; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import java.security.SecureRandom; - -public abstract class AbstractLiteClient { - - public Logger logger = LoggerFactory.getLogger(AbstractLiteClient.class); - - protected LiteClientConfig liteClientConfig; - - protected LoadBalanceSelector eventMeshServerSelector; - - public AbstractLiteClient(LiteClientConfig liteClientConfig) { - this.liteClientConfig = liteClientConfig; - } - - public void start() throws Exception { - eventMeshServerSelector = HttpLoadBalanceUtils.createEventMeshServerLoadBalanceSelector(liteClientConfig); - } - - public LiteClientConfig getLiteClientConfig() { - return liteClientConfig; - } - - public void shutdown() throws Exception { - logger.info("AbstractLiteClient shutdown"); - } - - public CloseableHttpClient setHttpClient() throws Exception { - if (!liteClientConfig.isUseTls()) { - return HttpClients.createDefault(); - } - SSLContext sslContext = null; - try { - String protocol = System.getProperty("ssl.client.protocol", "TLSv1.2"); - TrustManager[] tm = new TrustManager[]{new MyX509TrustManager()}; - sslContext = SSLContext.getInstance(protocol); - sslContext.init(null, tm, new SecureRandom()); - return HttpClients.custom().setSSLContext(sslContext) - .setSSLHostnameVerifier(new DefaultHostnameVerifier()).build(); - } catch (Exception e) { - logger.error("Error in creating HttpClient.", e); - throw e; - } - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/RemotingServer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/RemotingServer.java deleted file mode 100644 index 3c98d819c0..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/RemotingServer.java +++ /dev/null @@ -1,424 +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 org.apache.eventmesh.client.http; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOption; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.SimpleChannelInboundHandler; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.SocketChannel; -import io.netty.channel.socket.nio.NioServerSocketChannel; -import io.netty.handler.codec.http.DefaultFullHttpResponse; -import io.netty.handler.codec.http.FullHttpResponse; -import io.netty.handler.codec.http.HttpHeaderNames; -import io.netty.handler.codec.http.HttpHeaderValues; -import io.netty.handler.codec.http.HttpMethod; -import io.netty.handler.codec.http.HttpObjectAggregator; -import io.netty.handler.codec.http.HttpRequest; -import io.netty.handler.codec.http.HttpRequestDecoder; -import io.netty.handler.codec.http.HttpResponseEncoder; -import io.netty.handler.codec.http.HttpResponseStatus; -import io.netty.handler.codec.http.HttpVersion; -import io.netty.handler.codec.http.QueryStringDecoder; -import io.netty.handler.codec.http.multipart.Attribute; -import io.netty.handler.codec.http.multipart.DefaultHttpDataFactory; -import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder; -import io.netty.handler.codec.http.multipart.InterfaceHttpData; - -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.RandomUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.client.http.consumer.HandleResult; -import org.apache.eventmesh.client.http.consumer.context.LiteConsumeContext; -import org.apache.eventmesh.client.http.consumer.listener.LiteMessageListener; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.LiteMessage; -import org.apache.eventmesh.common.ThreadUtil; -import org.apache.eventmesh.common.command.HttpCommand; -import org.apache.eventmesh.common.protocol.http.body.Body; -import org.apache.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; -import org.apache.eventmesh.common.protocol.http.common.ClientRetCode; -import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; -import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; -import org.apache.eventmesh.common.protocol.http.common.RequestCode; -import org.apache.eventmesh.common.protocol.http.header.Header; -import org.apache.eventmesh.common.protocol.http.header.message.PushMessageRequestHeader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RemotingServer { - - public Logger logger = LoggerFactory.getLogger(this.getClass()); - - public AtomicBoolean started = new AtomicBoolean(Boolean.FALSE); - - public AtomicBoolean inited = new AtomicBoolean(Boolean.FALSE); - - private EventLoopGroup bossGroup; - - private EventLoopGroup workerGroup; - - private int port = RandomUtils.nextInt(1000, 20000); - - private DefaultHttpDataFactory defaultHttpDataFactory = new DefaultHttpDataFactory(false); - - private ThreadPoolExecutor consumeExecutor; - - private LiteMessageListener messageListener; - - public RemotingServer() { - } - - public RemotingServer(int port) { - this.port = port; - } - - public RemotingServer(ThreadPoolExecutor consumeExecutor) { - this.consumeExecutor = consumeExecutor; - } - - public RemotingServer(int port, ThreadPoolExecutor consumeExecutor) { - this.port = port; - this.consumeExecutor = consumeExecutor; - } - - public void setPort(int port) { - this.port = port; - } - - public void setConsumeExecutor(ThreadPoolExecutor consumeExecutor) { - this.consumeExecutor = consumeExecutor; - } - - // TODO: Let different topics have different listeners - public void registerMessageListener(LiteMessageListener eventMeshMessageListener) { - this.messageListener = eventMeshMessageListener; - } - - private EventLoopGroup initBossGroup() { - bossGroup = new NioEventLoopGroup(1, new ThreadFactory() { - AtomicInteger count = new AtomicInteger(0); - - @Override - public Thread newThread(Runnable r) { - Thread t = new Thread(r, "endPointBoss-" + count.incrementAndGet()); - t.setDaemon(true); - return t; - } - }); - - return bossGroup; - } - - private EventLoopGroup initWokerGroup() { - workerGroup = new NioEventLoopGroup(2, new ThreadFactory() { - AtomicInteger count = new AtomicInteger(0); - - @Override - public Thread newThread(Runnable r) { - Thread t = new Thread(r, "endpointWorker-" + count.incrementAndGet()); - return t; - } - }); - return workerGroup; - } - - public String getEndpointURL() { - return String.format("http://%s:%s", IPUtil.getLocalAddress(), port); - } - - - class HTTPHandler extends SimpleChannelInboundHandler { - - /** - * Parse request HEADER - * - * @param fullReq - * @return - */ - private Map parseHTTPHeader(HttpRequest fullReq) { - Map headerParam = new HashMap<>(); - for (String key : fullReq.headers().names()) { - if (StringUtils.equalsIgnoreCase(HttpHeaderNames.CONTENT_TYPE.toString(), key) - || StringUtils.equalsIgnoreCase(HttpHeaderNames.ACCEPT_ENCODING.toString(), key) - || StringUtils.equalsIgnoreCase(HttpHeaderNames.CONTENT_LENGTH.toString(), key)) { - continue; - } - headerParam.put(key, fullReq.headers().get(key)); - } - return headerParam; - } - - @Override - protected void channelRead0(final ChannelHandlerContext ctx, HttpRequest httpRequest) throws Exception { - HttpPostRequestDecoder decoder = null; - try { - if (!httpRequest.decoderResult().isSuccess()) { - sendError(ctx, HttpResponseStatus.BAD_REQUEST); - return; - } - - // Protocol version verification - String protocolVersion = StringUtils.deleteWhitespace(httpRequest.headers().get(ProtocolKey.VERSION)); - if (StringUtils.isBlank(protocolVersion) || !ProtocolVersion.contains(protocolVersion)) { - httpRequest.headers().set(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()); - } - - Map bodyMap = new HashMap<>(); - - if (httpRequest.method() == HttpMethod.GET) { - QueryStringDecoder getDecoder = new QueryStringDecoder(httpRequest.uri()); - for (Map.Entry> entry : getDecoder.parameters().entrySet()) { - bodyMap.put(entry.getKey(), entry.getValue().get(0)); - } - } else if (httpRequest.method() == HttpMethod.POST) { - decoder = new HttpPostRequestDecoder(defaultHttpDataFactory, httpRequest); - List parmList = decoder.getBodyHttpDatas(); - for (InterfaceHttpData parm : parmList) { - if (parm.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) { - Attribute data = (Attribute) parm; - bodyMap.put(data.getName(), data.getValue()); - } - } - } else { - sendError(ctx, HttpResponseStatus.METHOD_NOT_ALLOWED); - return; - } - - /////////////////////////////////////////////////////////////////Basic inspection//////////////////////////////////////////////////// - String requestCode = - (httpRequest.method() == HttpMethod.POST) ? StringUtils.deleteWhitespace(httpRequest.headers().get(ProtocolKey.REQUEST_CODE)) - : MapUtils.getString(bodyMap, StringUtils.lowerCase(ProtocolKey.REQUEST_CODE), ""); - - final HttpCommand requestCommand = new HttpCommand( - httpRequest.method().name(), - httpRequest.protocolVersion().protocolName(), requestCode); - - HttpCommand responseCommand; - - // Verify requestCode - if (StringUtils.isBlank(requestCode) - || !StringUtils.isNumeric(requestCode) - || (!String.valueOf(RequestCode.HTTP_PUSH_CLIENT_ASYNC.getRequestCode()).equals(requestCode) - && !String.valueOf(RequestCode.HTTP_PUSH_CLIENT_SYNC.getRequestCode()).equals(requestCode))) { - logger.error("receive invalid requestCode, {}", requestCode); - responseCommand = requestCommand.createHttpCommandResponse(ClientRetCode.OK.getRetCode(), ClientRetCode.OK.getErrMsg()); - sendResponse(ctx, responseCommand.httpResponse()); - return; - } - - requestCommand.setHeader(Header.buildHeader(requestCode, parseHTTPHeader(httpRequest))); - requestCommand.setBody(Body.buildBody(requestCode, bodyMap)); - - if (logger.isDebugEnabled()) { - logger.debug("{}", requestCommand); - } - - PushMessageRequestHeader pushMessageRequestHeader = (PushMessageRequestHeader) requestCommand.header; - PushMessageRequestBody pushMessageRequestBody = (PushMessageRequestBody) requestCommand.body; - - String topic = pushMessageRequestBody.getTopic(); - - // Check if there is a listener for the TOPIC -// if (!listenerTable.containsKey(topic)) { -// logger.error("no listenning for this topic, {}", topic); -// responseCommand = requestCommand.createHttpCommandResponse(ClientRetCode.NOLISTEN.getRetCode(), ClientRetCode.NOLISTEN.getErrMsg()); -// sendResponse(ctx, responseCommand.httpResponse()); -// return; -// } - - final LiteConsumeContext eventMeshConsumeContext = new LiteConsumeContext(pushMessageRequestHeader.getEventMeshIp(), - pushMessageRequestHeader.getEventMeshEnv(), pushMessageRequestHeader.getEventMeshIdc(), - pushMessageRequestHeader.getEventMeshCluster()); - - final LiteMessage liteMessage = new LiteMessage(pushMessageRequestBody.getBizSeqNo(), pushMessageRequestBody.getUniqueId(), - topic, pushMessageRequestBody.getContent()); - - for (Map.Entry entry : pushMessageRequestBody.getExtFields().entrySet()) { - liteMessage.addProp(entry.getKey(), entry.getValue()); - } - - // Transfer to the consumer thread pool - consumeExecutor.execute(new Runnable() { - @Override - public void run() { - try { - if (messageListener.reject()) { - HttpCommand responseCommand = requestCommand.createHttpCommandResponse(handleResult2ClientRetCode(HandleResult.RETRY).getRetCode(), handleResult2ClientRetCode(HandleResult.RETRY).getErrMsg()); - sendResponse(ctx, responseCommand.httpResponse()); - return; - } - - HandleResult handleResult = messageListener.handle(liteMessage, eventMeshConsumeContext); - - if (logger.isDebugEnabled()) { - logger.info("bizSeqNo:{}, topic:{}, handleResult:{}", liteMessage.getBizSeqNo(), liteMessage.getTopic(), handleResult); - } - - HttpCommand responseCommand = requestCommand.createHttpCommandResponse(handleResult2ClientRetCode(handleResult).getRetCode(), handleResult2ClientRetCode(handleResult).getErrMsg()); - sendResponse(ctx, responseCommand.httpResponse()); - } catch (Exception e) { - logger.error("process error", e); - } - } - }); - } catch (Exception ex) { - logger.error("HTTPHandler.channelRead0 err", ex); - } finally { - try { - decoder.destroy(); - } catch (Exception e) { - } - } - } - - public ClientRetCode handleResult2ClientRetCode(HandleResult handleResult) { - if (handleResult == HandleResult.OK) { - return ClientRetCode.OK; - } else if (handleResult == HandleResult.FAIL) { - return ClientRetCode.FAIL; - } else if (handleResult == HandleResult.NOLISTEN) { - return ClientRetCode.NOLISTEN; - } else if (handleResult == HandleResult.RETRY) { - return ClientRetCode.RETRY; - } else { - return ClientRetCode.OK; - } - } - - @Override - public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { - super.channelReadComplete(ctx); - ctx.flush(); // 4 - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - if (null != cause) cause.printStackTrace(); - if (null != ctx) ctx.close(); - } - - /** - * Send default error page - * - * @param ctx - * @param status - */ - private void sendError(ChannelHandlerContext ctx, - HttpResponseStatus status) { - FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, - status); - response.headers().add(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN + - "; charset=" + Constants.DEFAULT_CHARSET); - response.headers().add(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes()); - response.headers().add(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE); - ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); - } - - - /** - * Send response - * - * @param ctx - * @param response - */ - private void sendResponse(ChannelHandlerContext ctx, - DefaultFullHttpResponse response) { - ctx.writeAndFlush(response).addListener(new ChannelFutureListener() { - @Override - public void operationComplete(ChannelFuture f) throws Exception { - if (!f.isSuccess()) { - logger.warn("send response to [{}] fail, will close this channel", IPUtil.parseChannelRemoteAddr(f.channel())); - f.channel().close(); - return; - } - } - }); - } - - public void shutdown() throws Exception { - if (bossGroup != null) { - bossGroup.shutdownGracefully(); - } - - ThreadUtil.randomSleep(30); - - if (workerGroup != null) { - workerGroup.shutdownGracefully(); - } - - started.compareAndSet(true, false); - inited.compareAndSet(true, false); - } - } - - public void init() throws Exception { - initBossGroup(); - initWokerGroup(); - inited.compareAndSet(false, true); - } - - public void start() throws Exception { - Runnable r = new Runnable() { - @Override - public void run() { - ServerBootstrap b = new ServerBootstrap(); - b.group(bossGroup, workerGroup) - .channel(NioServerSocketChannel.class) - .childHandler(new ChannelInitializer() { - @Override - public void initChannel(SocketChannel ch) - throws Exception { - ch.pipeline() - .addLast(new HttpRequestDecoder(), - new HttpResponseEncoder(), - new HttpObjectAggregator(Integer.MAX_VALUE), - new HTTPHandler()); // 4 - } - }).childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE); - try { - logger.info("EventMesh Client[{}] Started......", port); - ChannelFuture future = b.bind(port).sync(); - future.channel().closeFuture().sync(); - started.compareAndSet(false, true); - } catch (Exception e) { - bossGroup.shutdownGracefully(); - workerGroup.shutdownGracefully(); - } - } - }; - - - Thread t = new Thread(r, "eventMesh-client-remoting-server"); - t.start(); - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/conf/EventMeshHttpClientConfig.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/conf/EventMeshHttpClientConfig.java new file mode 100644 index 0000000000..24dfd0fee4 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/conf/EventMeshHttpClientConfig.java @@ -0,0 +1,80 @@ +/* + * Licensed 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.eventmesh.client.http.conf; + +import org.apache.eventmesh.common.loadbalance.LoadBalanceType; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class EventMeshHttpClientConfig { + + /** + * The event server address list + *

+ * If it's a cluster, please use ; to split, and the address format is related to loadBalanceType. + *

+ * E.g. + *

If you use Random strategy, the format like: 127.0.0.1:10105;127.0.0.2:10105 + *

If you use weighted round robin or weighted random strategy, the format like: 127.0.0.1:10105:1;127.0.0.2:10105:2 + */ + @Builder.Default + private String liteEventMeshAddr = "127.0.0.1:10105"; + + @Builder.Default + private LoadBalanceType loadBalanceType = LoadBalanceType.RANDOM; + + @Builder.Default + private int consumeThreadCore = 2; + + @Builder.Default + private int consumeThreadMax = 5; + + @Builder.Default + private String env = ""; + + @Builder.Default + private String consumerGroup = "DefaultConsumerGroup"; + + @Builder.Default + private String producerGroup = "DefaultProducerGroup"; + + @Builder.Default + private String idc = ""; + + @Builder.Default + private String ip = "127.0.0.1"; + + @Builder.Default + private String pid = ""; + + @Builder.Default + private String sys = ""; + + @Builder.Default + private String userName = ""; + + @Builder.Default + private String password = ""; + + @Builder.Default + private boolean useTls = false; + +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/conf/LiteClientConfig.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/conf/LiteClientConfig.java deleted file mode 100644 index c302523fa6..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/conf/LiteClientConfig.java +++ /dev/null @@ -1,207 +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 org.apache.eventmesh.client.http.conf; - -import org.apache.eventmesh.common.loadbalance.LoadBalanceType; - -public class LiteClientConfig { - - /** - * The event server address list - *

- * If it's a cluster, please use ; to split, and the address format is related to loadBalanceType. - *

- * E.g. - *

If you use Random strategy, the format like: 127.0.0.1:10105;127.0.0.2:10105 - *

If you use weighted round robin or weighted random strategy, the format like: 127.0.0.1:10105:1;127.0.0.2:10105:2 - */ - private String liteEventMeshAddr = "127.0.0.1:10105"; - - private LoadBalanceType loadBalanceType = LoadBalanceType.RANDOM; - - private int consumeThreadCore = 2; - - private int consumeThreadMax = 5; - - private String env; - - private String consumerGroup = "DefaultConsumerGroup"; - - private String producerGroup = "DefaultProducerGroup"; - - private String idc; - - private String ip = "127.0.0.1"; - - private String pid; - - private String sys; - - private String userName; - - private String password; - - private boolean useTls = false; - - public String getLiteEventMeshAddr() { - return liteEventMeshAddr; - } - - public LiteClientConfig setLiteEventMeshAddr(String liteEventMeshAddr) { - this.liteEventMeshAddr = liteEventMeshAddr; - return this; - } - - public LoadBalanceType getLoadBalanceType() { - return loadBalanceType; - } - - public LiteClientConfig setLoadBalanceType(LoadBalanceType loadBalanceType) { - this.loadBalanceType = loadBalanceType; - return this; - } - - public int getConsumeThreadCore() { - return consumeThreadCore; - } - - public LiteClientConfig setConsumeThreadCore(int consumeThreadCore) { - this.consumeThreadCore = consumeThreadCore; - return this; - } - - public int getConsumeThreadMax() { - return consumeThreadMax; - } - - public LiteClientConfig setConsumeThreadMax(int consumeThreadMax) { - this.consumeThreadMax = consumeThreadMax; - return this; - } - - public String getEnv() { - return env; - } - - public LiteClientConfig setEnv(String env) { - this.env = env; - return this; - } - - public String getIdc() { - return idc; - } - - public LiteClientConfig setIdc(String idc) { - this.idc = idc; - return this; - } - - public String getIp() { - return ip; - } - - public LiteClientConfig setIp(String ip) { - this.ip = ip; - return this; - } - - public String getPid() { - return pid; - } - - public LiteClientConfig setPid(String pid) { - this.pid = pid; - return this; - } - - public String getSys() { - return sys; - } - - public LiteClientConfig setSys(String sys) { - this.sys = sys; - return this; - } - - public String getUserName() { - return userName; - } - - public LiteClientConfig setUserName(String userName) { - this.userName = userName; - return this; - } - - public String getPassword() { - return password; - } - - public LiteClientConfig setPassword(String password) { - this.password = password; - return this; - } - - public boolean isUseTls() { - return useTls; - } - - public LiteClientConfig setUseTls(boolean useTls) { - this.useTls = useTls; - return this; - } - - public String getConsumerGroup() { - return consumerGroup; - } - - public LiteClientConfig setConsumerGroup(String consumerGroup) { - this.consumerGroup = consumerGroup; - return this; - } - - public String getProducerGroup() { - return producerGroup; - } - - public LiteClientConfig setProducerGroup(String producerGroup) { - this.producerGroup = producerGroup; - return this; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("liteClientConfig={") - .append("liteEventMeshAddr=").append(liteEventMeshAddr).append(",") - .append("loadBalanceType=").append(loadBalanceType).append(",") - .append("consumeThreadCore=").append(consumeThreadCore).append(",") - .append("consumeThreadMax=").append(consumeThreadMax).append(",") - .append("env=").append(env).append(",") - .append("idc=").append(idc).append(",") - .append("producerGroup=").append(producerGroup).append(",") - .append("consumerGroup=").append(consumerGroup).append(",") - .append("ip=").append(ip).append(",") - .append("pid=").append(pid).append(",") - .append("sys=").append(sys).append(",") - .append("userName=").append(userName).append(",") - .append("password=").append(password).append(",") - .append("useTls=").append(useTls).append("}"); - return sb.toString(); - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/EventMeshHttpConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/EventMeshHttpConsumer.java new file mode 100644 index 0000000000..00c544a261 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/EventMeshHttpConsumer.java @@ -0,0 +1,192 @@ +/* + * Licensed 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.eventmesh.client.http.consumer; + +import org.apache.eventmesh.client.http.AbstractHttpClient; +import org.apache.eventmesh.client.http.EventMeshRetObj; +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.model.RequestParam; +import org.apache.eventmesh.client.http.util.HttpUtils; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.ThreadPoolFactory; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.SubscriptionItem; +import org.apache.eventmesh.common.protocol.http.body.client.HeartbeatRequestBody; +import org.apache.eventmesh.common.protocol.http.body.client.SubscribeRequestBody; +import org.apache.eventmesh.common.protocol.http.body.client.UnSubscribeRequestBody; +import org.apache.eventmesh.common.protocol.http.common.ClientType; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.utils.JsonUtils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.ThreadFactoryBuilder; + +import io.netty.handler.codec.http.HttpMethod; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class EventMeshHttpConsumer extends AbstractHttpClient implements AutoCloseable { + + private final ThreadPoolExecutor consumeExecutor; + + private static final List SUBSCRIPTIONS = Collections.synchronizedList(new ArrayList<>()); + + private final ScheduledThreadPoolExecutor scheduler; + + public EventMeshHttpConsumer(EventMeshHttpClientConfig eventMeshHttpClientConfig) throws EventMeshException { + this(eventMeshHttpClientConfig, null); + } + + public EventMeshHttpConsumer(EventMeshHttpClientConfig eventMeshHttpClientConfig, ThreadPoolExecutor customExecutor) + throws EventMeshException { + super(eventMeshHttpClientConfig); + this.consumeExecutor = Optional.ofNullable(customExecutor).orElseGet( + () -> ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpClientConfig.getConsumeThreadCore(), + eventMeshHttpClientConfig.getConsumeThreadMax(), "EventMesh-client-consume-") + ); + this.scheduler = new ScheduledThreadPoolExecutor( + Runtime.getRuntime().availableProcessors(), + new ThreadFactoryBuilder().setNameFormat("HTTPClientScheduler").setDaemon(true).build() + ); + } + + /** + * When receive message will callback the url. + * + * @param topicList topic that be subscribed + * @param subscribeUrl url will be trigger + * @throws EventMeshException if subscribe failed + */ + public void subscribe(List topicList, String subscribeUrl) throws EventMeshException { + Preconditions.checkNotNull(topicList, "Subscribe item cannot be null"); + Preconditions.checkNotNull(subscribeUrl, "SubscribeUrl cannot be null"); + RequestParam subscribeParam = buildCommonRequestParam() + .addHeader(ProtocolKey.REQUEST_CODE, RequestCode.SUBSCRIBE.getRequestCode()) + .addBody(SubscribeRequestBody.TOPIC, JsonUtils.serialize(topicList)) + .addBody(SubscribeRequestBody.CONSUMERGROUP, eventMeshHttpClientConfig.getConsumerGroup()) + .addBody(SubscribeRequestBody.URL, subscribeUrl); + + String target = selectEventMesh(); + try { + String subRes = HttpUtils.post(httpClient, target, subscribeParam); + EventMeshRetObj ret = JsonUtils.deserialize(subRes, EventMeshRetObj.class); + if (ret.getRetCode() != EventMeshRetCode.SUCCESS.getRetCode()) { + throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); + } + SUBSCRIPTIONS.addAll(topicList); + } catch (Exception ex) { + throw new EventMeshException(String.format("Subscribe topic error, target:%s", target), ex); + } + } + + // todo: remove http heartBeat? + public void heartBeat(List topicList, String subscribeUrl) { + Preconditions.checkNotNull(topicList, "Subscribe item cannot be null"); + Preconditions.checkNotNull(subscribeUrl, "SubscribeUrl cannot be null"); + scheduler.scheduleAtFixedRate(() -> { + try { + List heartbeatEntities = topicList.stream().map(subscriptionItem + -> { + HeartbeatRequestBody.HeartbeatEntity heartbeatEntity = new HeartbeatRequestBody.HeartbeatEntity(); + heartbeatEntity.topic = subscriptionItem.getTopic(); + heartbeatEntity.url = subscribeUrl; + return heartbeatEntity; + }).collect(Collectors.toList()); + RequestParam requestParam = buildCommonRequestParam() + .addHeader(ProtocolKey.REQUEST_CODE, RequestCode.HEARTBEAT.getRequestCode()) + .addBody(HeartbeatRequestBody.CLIENTTYPE, ClientType.SUB.name()) + .addBody(HeartbeatRequestBody.HEARTBEATENTITIES, JsonUtils.serialize(heartbeatEntities)); + String target = selectEventMesh(); + String res = HttpUtils.post(httpClient, target, requestParam); + EventMeshRetObj ret = JsonUtils.deserialize(res, EventMeshRetObj.class); + if (ret.getRetCode() != EventMeshRetCode.SUCCESS.getRetCode()) { + throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); + } + } catch (Exception e) { + log.error("send heartBeat error", e); + } + }, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS); + } + + /** + * @param topicList subscribe topic + * @param unSubscribeUrl subscribeUrl + * @throws EventMeshException if unsubscribe failed + */ + public void unsubscribe(List topicList, String unSubscribeUrl) throws EventMeshException { + Preconditions.checkNotNull(topicList, "Topics cannot be null"); + Preconditions.checkNotNull(unSubscribeUrl, "unSubscribeUrl cannot be null"); + RequestParam unSubscribeParam = buildCommonRequestParam() + .addHeader(ProtocolKey.REQUEST_CODE, RequestCode.UNSUBSCRIBE.getRequestCode()) + .addBody(UnSubscribeRequestBody.TOPIC, JsonUtils.serialize(topicList)) + .addBody(UnSubscribeRequestBody.URL, unSubscribeUrl); + String target = selectEventMesh(); + try { + String unSubRes = HttpUtils.post(httpClient, target, unSubscribeParam); + EventMeshRetObj ret = JsonUtils.deserialize(unSubRes, EventMeshRetObj.class); + + if (ret.getRetCode() != EventMeshRetCode.SUCCESS.getRetCode()) { + throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); + } + // todo: avoid concurrentModifiedException + SUBSCRIPTIONS.removeIf(item -> topicList.contains(item.getTopic())); + } catch (Exception ex) { + throw new EventMeshException(String.format("Unsubscribe topic error, target:%s", target), ex); + } + } + + @Override + public void close() throws EventMeshException { + log.info("LiteConsumer shutting down"); + super.close(); + if (consumeExecutor != null) { + consumeExecutor.shutdown(); + } + scheduler.shutdown(); + log.info("LiteConsumer shutdown"); + } + + private RequestParam buildCommonRequestParam() { + return new RequestParam(HttpMethod.POST) + .addHeader(ProtocolKey.ClientInstanceKey.ENV, eventMeshHttpClientConfig.getEnv()) + .addHeader(ProtocolKey.ClientInstanceKey.IDC, eventMeshHttpClientConfig.getIdc()) + .addHeader(ProtocolKey.ClientInstanceKey.IP, eventMeshHttpClientConfig.getIp()) + .addHeader(ProtocolKey.ClientInstanceKey.PID, eventMeshHttpClientConfig.getPid()) + .addHeader(ProtocolKey.ClientInstanceKey.SYS, eventMeshHttpClientConfig.getSys()) + .addHeader(ProtocolKey.ClientInstanceKey.USERNAME, eventMeshHttpClientConfig.getUserName()) + .addHeader(ProtocolKey.ClientInstanceKey.PASSWD, eventMeshHttpClientConfig.getPassword()) + // add protocol version? + .addHeader(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()) + .addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA) + .setTimeout(Constants.DEFAULT_HTTP_TIME_OUT) + .addBody(HeartbeatRequestBody.CONSUMERGROUP, eventMeshHttpClientConfig.getConsumerGroup()); + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/LiteConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/LiteConsumer.java deleted file mode 100644 index 7915d40245..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/LiteConsumer.java +++ /dev/null @@ -1,318 +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 org.apache.eventmesh.client.http.consumer; - -import org.apache.eventmesh.client.http.AbstractLiteClient; -import org.apache.eventmesh.client.http.EventMeshRetObj; -import org.apache.eventmesh.client.http.RemotingServer; -import org.apache.eventmesh.client.http.conf.LiteClientConfig; -import org.apache.eventmesh.client.http.consumer.listener.LiteMessageListener; -import org.apache.eventmesh.client.http.http.HttpUtil; -import org.apache.eventmesh.client.http.http.RequestParam; -import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.client.tcp.common.EventMeshThreadFactoryImpl; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.EventMeshException; -import org.apache.eventmesh.common.ThreadPoolFactory; -import org.apache.eventmesh.common.protocol.SubscriptionItem; -import org.apache.eventmesh.common.protocol.http.body.client.HeartbeatRequestBody; -import org.apache.eventmesh.common.protocol.http.body.client.SubscribeRequestBody; -import org.apache.eventmesh.common.protocol.http.body.client.UnSubscribeRequestBody; -import org.apache.eventmesh.common.protocol.http.common.ClientType; -import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; -import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; -import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; -import org.apache.eventmesh.common.protocol.http.common.RequestCode; -import org.apache.eventmesh.common.utils.JsonUtils; - -import org.apache.http.impl.client.CloseableHttpClient; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; - -import io.netty.handler.codec.http.HttpMethod; - -public class LiteConsumer extends AbstractLiteClient { - - public Logger logger = LoggerFactory.getLogger(LiteConsumer.class); - - private RemotingServer remotingServer; - - private ThreadPoolExecutor consumeExecutor; - - protected LiteClientConfig eventMeshClientConfig; - - private List subscription = Lists.newArrayList(); - - private LiteMessageListener messageListener; - - protected final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(4, - new EventMeshThreadFactoryImpl("TCPClientScheduler", true)); - - public LiteConsumer(LiteClientConfig liteClientConfig) throws Exception { - super(liteClientConfig); - this.consumeExecutor = - ThreadPoolFactory.createThreadPoolExecutor(liteClientConfig.getConsumeThreadCore(), - liteClientConfig.getConsumeThreadMax(), "eventMesh-client-consume-"); - this.eventMeshClientConfig = liteClientConfig; -// this.remotingServer = new RemotingServer(10106, consumeExecutor); -// this.remotingServer.init(); - } - - public LiteConsumer(LiteClientConfig liteClientConfig, - ThreadPoolExecutor customExecutor) { - super(liteClientConfig); - this.consumeExecutor = customExecutor; - this.eventMeshClientConfig = liteClientConfig; -// this.remotingServer = new RemotingServer(this.consumeExecutor); - } - - private final AtomicBoolean started = new AtomicBoolean(Boolean.FALSE); - - @Override - public void start() throws Exception { - Preconditions - .checkState(eventMeshClientConfig != null, "eventMeshClientConfig can't be null"); - Preconditions.checkState(consumeExecutor != null, "consumeExecutor can't be null"); -// Preconditions.checkState(messageListener != null, "messageListener can't be null"); - logger.info("LiteConsumer starting"); - super.start(); - started.compareAndSet(false, true); - logger.info("LiteConsumer started"); -// this.remotingServer.start(); - } - - @Override - public void shutdown() throws Exception { - logger.info("LiteConsumer shutting down"); - super.shutdown(); - if (consumeExecutor != null) { - consumeExecutor.shutdown(); - } - scheduler.shutdown(); - started.compareAndSet(true, false); - logger.info("LiteConsumer shutdown"); - } - - public boolean subscribe(List topicList, String url) throws Exception { - subscription.addAll(topicList); - if (!started.get()) { - start(); - } - - RequestParam subscribeParam = generateSubscribeRequestParam(topicList, url); - - long startTime = System.currentTimeMillis(); - String target = selectEventMesh(); - String subRes = ""; - - try (CloseableHttpClient httpClient = setHttpClient()) { - subRes = HttpUtil.post(httpClient, target, subscribeParam); - } - - if (logger.isDebugEnabled()) { - logger.debug( - "subscribe message by await, targetEventMesh:{}, cost:{}ms, subscribeParam:{}, " - + "rtn:{}", target, System.currentTimeMillis() - startTime, - JsonUtils.serialize(subscribeParam), subRes); - } - - EventMeshRetObj ret = JsonUtils.deserialize(subRes, EventMeshRetObj.class); - - if (ret.getRetCode() == EventMeshRetCode.SUCCESS.getRetCode()) { - return Boolean.TRUE; - } else { - throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); - } - - } - - private RequestParam generateSubscribeRequestParam(List topicList, - String url) { -// final LiteMessage liteMessage = new LiteMessage(); -// liteMessage.setBizSeqNo(RandomStringUtils.randomNumeric(30)) -// .setContent("subscribe message") -// .setUniqueId(RandomStringUtils.randomNumeric(30)); - RequestParam requestParam = new RequestParam(HttpMethod.POST); - requestParam.addHeader(ProtocolKey.REQUEST_CODE, - String.valueOf(RequestCode.SUBSCRIBE.getRequestCode())) - .addHeader(ProtocolKey.ClientInstanceKey.ENV, eventMeshClientConfig.getEnv()) - .addHeader(ProtocolKey.ClientInstanceKey.IDC, eventMeshClientConfig.getIdc()) - .addHeader(ProtocolKey.ClientInstanceKey.IP, eventMeshClientConfig.getIp()) - .addHeader(ProtocolKey.ClientInstanceKey.PID, eventMeshClientConfig.getPid()) - .addHeader(ProtocolKey.ClientInstanceKey.SYS, eventMeshClientConfig.getSys()) - .addHeader(ProtocolKey.ClientInstanceKey.USERNAME, eventMeshClientConfig.getUserName()) - .addHeader(ProtocolKey.ClientInstanceKey.PASSWD, eventMeshClientConfig.getPassword()) - .addHeader(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()) - .addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA) - .setTimeout(Constants.DEFAULT_HTTP_TIME_OUT) - .addBody(SubscribeRequestBody.TOPIC, JsonUtils.serialize(topicList)) - .addBody(SubscribeRequestBody.CONSUMERGROUP, eventMeshClientConfig.getConsumerGroup()) - .addBody(SubscribeRequestBody.URL, url); - return requestParam; - } - - private RequestParam generateHeartBeatRequestParam(List topics, String url) { - List heartbeatEntities = new ArrayList<>(); - for (SubscriptionItem item : topics) { - HeartbeatRequestBody.HeartbeatEntity heartbeatEntity = - new HeartbeatRequestBody.HeartbeatEntity(); - heartbeatEntity.topic = item.getTopic(); - heartbeatEntity.url = url; - heartbeatEntities.add(heartbeatEntity); - } - - RequestParam requestParam = new RequestParam(HttpMethod.POST); - requestParam.addHeader(ProtocolKey.REQUEST_CODE, - String.valueOf(RequestCode.HEARTBEAT.getRequestCode())) - .addHeader(ProtocolKey.ClientInstanceKey.ENV, eventMeshClientConfig.getEnv()) - .addHeader(ProtocolKey.ClientInstanceKey.IDC, eventMeshClientConfig.getIdc()) - .addHeader(ProtocolKey.ClientInstanceKey.IP, eventMeshClientConfig.getIp()) - .addHeader(ProtocolKey.ClientInstanceKey.PID, eventMeshClientConfig.getPid()) - .addHeader(ProtocolKey.ClientInstanceKey.SYS, eventMeshClientConfig.getSys()) - .addHeader(ProtocolKey.ClientInstanceKey.USERNAME, eventMeshClientConfig.getUserName()) - .addHeader(ProtocolKey.ClientInstanceKey.PASSWD, eventMeshClientConfig.getPassword()) - .addHeader(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()) - .addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA) - .setTimeout(Constants.DEFAULT_HTTP_TIME_OUT) - .addBody(HeartbeatRequestBody.CLIENTTYPE, ClientType.SUB.name()) - .addBody(HeartbeatRequestBody.CONSUMERGROUP, eventMeshClientConfig.getConsumerGroup()) - .addBody(HeartbeatRequestBody.HEARTBEATENTITIES, - JsonUtils.serialize(heartbeatEntities)); - return requestParam; - } - - public void heartBeat(List topicList, String url) throws Exception { - scheduler.scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - try { - if (!started.get()) { - start(); - } - RequestParam requestParam = generateHeartBeatRequestParam(topicList, url); - - long startTime = System.currentTimeMillis(); - String target = selectEventMesh(); - String res = ""; - - try (CloseableHttpClient httpClient = setHttpClient()) { - res = HttpUtil.post(httpClient, target, requestParam); - } - - if (logger.isDebugEnabled()) { - logger.debug( - "heartBeat message by await, targetEventMesh:{}, cost:{}ms, rtn:{}", - target, System.currentTimeMillis() - startTime, res); - } - - EventMeshRetObj ret = JsonUtils.deserialize(res, EventMeshRetObj.class); - - if (ret.getRetCode() != EventMeshRetCode.SUCCESS.getRetCode()) { - throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); - } - } catch (Exception e) { - logger.error("send heartBeat error", e); - } - } - }, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS); - } - - public boolean unsubscribe(List topicList, String url) throws Exception { - Set unSub = new HashSet<>(topicList); - Iterator itr = subscription.iterator(); - while (itr.hasNext()) { - SubscriptionItem item = itr.next(); - if (unSub.contains(item.getTopic())) { - itr.remove(); - } - } - - RequestParam unSubscribeParam = generateUnSubscribeRequestParam(topicList, url); - - long startTime = System.currentTimeMillis(); - String target = selectEventMesh(); - String unSubRes = ""; - - try (CloseableHttpClient httpClient = setHttpClient()) { - unSubRes = HttpUtil.post(httpClient, target, unSubscribeParam); - } - - if (logger.isDebugEnabled()) { - logger.debug( - "unSubscribe message by await, targetEventMesh:{}, cost:{}ms, unSubscribeParam:{}, " - + "rtn:{}", target, System.currentTimeMillis() - startTime, - JsonUtils.serialize(unSubscribeParam), unSubRes); - } - - EventMeshRetObj ret = JsonUtils.deserialize(unSubRes, EventMeshRetObj.class); - - if (ret.getRetCode() == EventMeshRetCode.SUCCESS.getRetCode()) { - return Boolean.TRUE; - } else { - throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); - } - } - - private RequestParam generateUnSubscribeRequestParam(List topicList, String url) { - RequestParam requestParam = new RequestParam(HttpMethod.POST); - requestParam.addHeader(ProtocolKey.REQUEST_CODE, - String.valueOf(RequestCode.UNSUBSCRIBE.getRequestCode())) - .addHeader(ProtocolKey.ClientInstanceKey.ENV, eventMeshClientConfig.getEnv()) - .addHeader(ProtocolKey.ClientInstanceKey.IDC, eventMeshClientConfig.getIdc()) - .addHeader(ProtocolKey.ClientInstanceKey.IP, eventMeshClientConfig.getIp()) - .addHeader(ProtocolKey.ClientInstanceKey.PID, eventMeshClientConfig.getPid()) - .addHeader(ProtocolKey.ClientInstanceKey.SYS, eventMeshClientConfig.getSys()) - .addHeader(ProtocolKey.ClientInstanceKey.USERNAME, eventMeshClientConfig.getUserName()) - .addHeader(ProtocolKey.ClientInstanceKey.PASSWD, eventMeshClientConfig.getPassword()) - .addHeader(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()) - .addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA) - .setTimeout(Constants.DEFAULT_HTTP_TIME_OUT) - .addBody(UnSubscribeRequestBody.TOPIC, JsonUtils.serialize(topicList)) - .addBody(UnSubscribeRequestBody.CONSUMERGROUP, eventMeshClientConfig.getConsumerGroup()) - .addBody(UnSubscribeRequestBody.URL, url); - return requestParam; - } - - public void registerMessageListener(LiteMessageListener messageListener) - throws EventMeshException { - this.messageListener = messageListener; - remotingServer.registerMessageListener(this.messageListener); - } - - public String selectEventMesh() { - if (liteClientConfig.isUseTls()) { - return Constants.HTTPS_PROTOCOL_PREFIX + eventMeshServerSelector.select(); - } else { - return Constants.HTTP_PROTOCOL_PREFIX + eventMeshServerSelector.select(); - } - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/listener/LiteMessageListener.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/listener/LiteMessageListener.java index c7f5ac99af..38ac5b2705 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/listener/LiteMessageListener.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/listener/LiteMessageListener.java @@ -20,11 +20,11 @@ import org.apache.eventmesh.client.http.consumer.HandleResult; import org.apache.eventmesh.client.http.consumer.context.LiteConsumeContext; -import org.apache.eventmesh.common.LiteMessage; +import org.apache.eventmesh.common.EventMeshMessage; public interface LiteMessageListener { - HandleResult handle(LiteMessage liteMessage, LiteConsumeContext liteConsumeContext); + HandleResult handle(EventMeshMessage eventMeshMessage, LiteConsumeContext liteConsumeContext); boolean reject(); diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/http/RequestParam.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/model/RequestParam.java similarity index 85% rename from eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/http/RequestParam.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/model/RequestParam.java index 4d23222352..2e33444285 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/http/RequestParam.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/model/RequestParam.java @@ -15,7 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.client.http.http; +package org.apache.eventmesh.client.http.model; + +import org.apache.eventmesh.common.Constants; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -24,23 +26,20 @@ import java.util.Map; import io.netty.handler.codec.http.HttpMethod; +import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +@Slf4j public class RequestParam { - public Logger logger = LoggerFactory.getLogger(this.getClass()); - private Map queryParams; - private HttpMethod httpMethod; + private final HttpMethod httpMethod; private Map body; private Map headers; - private long timeout; + private long timeout = Constants.DEFAULT_HTTP_TIME_OUT; public RequestParam(HttpMethod httpMethod) { this.httpMethod = httpMethod; @@ -81,16 +80,16 @@ public String getQueryParams() { for (Map.Entry query : queryParams.entrySet()) { for (String val : query.getValue()) { stringBuilder.append("&") - .append(URLEncoder.encode(query.getKey(), "UTF-8")); + .append(URLEncoder.encode(query.getKey(), "UTF-8")); if (val != null && !val.isEmpty()) { stringBuilder.append("=") - .append(URLEncoder.encode(val, "UTF-8")); + .append(URLEncoder.encode(val, "UTF-8")); } } } } catch (UnsupportedEncodingException e) { - logger.error("get query params failed.", e); + log.error("get query params failed.", e); return ""; } return stringBuilder.substring(1); @@ -106,18 +105,18 @@ public RequestParam addQueryParam(String key, String value) { queryParams = new HashMap<>(); } if (!queryParams.containsKey(key)) { - queryParams.put(key, new String[]{value}); + queryParams.put(key, new String[] {value}); } else { queryParams.put(key, (String[]) Arrays.asList(queryParams.get(key), value).toArray()); } return this; } - public RequestParam addHeader(String key, String value) { + public RequestParam addHeader(String key, Object value) { if (headers == null) { headers = new HashMap<>(); } - headers.put(key, value); + headers.put(key, value.toString()); return this; } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/CloudEventProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/CloudEventProducer.java new file mode 100644 index 0000000000..9a4ac1d985 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/CloudEventProducer.java @@ -0,0 +1,169 @@ +/* + * Licensed 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.eventmesh.client.http.producer; + +import org.apache.eventmesh.client.http.AbstractHttpClient; +import org.apache.eventmesh.client.http.EventMeshRetObj; +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.model.RequestParam; +import org.apache.eventmesh.client.http.util.HttpUtils; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +import com.google.common.base.Preconditions; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import io.cloudevents.core.provider.EventFormatProvider; +import io.netty.handler.codec.http.HttpMethod; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class CloudEventProducer extends AbstractHttpClient implements EventMeshProtocolProducer { + + private static final String PROTOCOL_TYPE = "cloudevents"; + + private static final String PROTOCOL_DESC = "http"; + + public CloudEventProducer(EventMeshHttpClientConfig eventMeshHttpClientConfig) throws EventMeshException { + super(eventMeshHttpClientConfig); + } + + @Override + public void publish(CloudEvent cloudEvent) throws EventMeshException { + validateCloudEvent(cloudEvent); + CloudEvent enhanceCloudEvent = enhanceCloudEvent(cloudEvent); + // todo: Can put to abstract class, all protocol use the same send method? This can be a template method + RequestParam requestParam = buildCommonPostParam(enhanceCloudEvent) + .addHeader(ProtocolKey.REQUEST_CODE, RequestCode.MSG_SEND_ASYNC.getRequestCode()); + String target = selectEventMesh(); + try { + String response = HttpUtils.post(httpClient, target, requestParam); + EventMeshRetObj ret = JsonUtils.deserialize(response, EventMeshRetObj.class); + + if (ret.getRetCode() != EventMeshRetCode.SUCCESS.getRetCode()) { + throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); + } + } catch (Exception exception) { + throw new EventMeshException(String.format("Publish message error, target:%s", target), exception); + } + + } + + @Override + public CloudEvent request(CloudEvent cloudEvent, long timeout) throws EventMeshException { + validateCloudEvent(cloudEvent); + CloudEvent enhanceCloudEvent = enhanceCloudEvent(cloudEvent); + RequestParam requestParam = buildCommonPostParam(enhanceCloudEvent) + .addHeader(ProtocolKey.REQUEST_CODE, RequestCode.MSG_SEND_SYNC.getRequestCode()) + .setTimeout(timeout); + String target = selectEventMesh(); + + try { + String response = HttpUtils.post(httpClient, target, requestParam); + EventMeshRetObj ret = JsonUtils.deserialize(response, EventMeshRetObj.class); + if (ret.getRetCode() == EventMeshRetCode.SUCCESS.getRetCode()) { + return transformMessage(ret); + } + throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); + } catch (Exception e) { + throw new EventMeshException(String.format("Request message error, target:%s", target), e); + } + } + + @Override + public void request(final CloudEvent cloudEvent, final RRCallback rrCallback, long timeout) + throws EventMeshException { + validateCloudEvent(cloudEvent); + CloudEvent enhanceCloudEvent = enhanceCloudEvent(cloudEvent); + RequestParam requestParam = buildCommonPostParam(enhanceCloudEvent) + .addHeader(ProtocolKey.REQUEST_CODE, RequestCode.MSG_SEND_SYNC.getRequestCode()) + .setTimeout(timeout); + String target = selectEventMesh(); + RRCallbackResponseHandlerAdapter adapter = new RRCallbackResponseHandlerAdapter<>( + enhanceCloudEvent, rrCallback, timeout); + try { + HttpUtils.post(httpClient, null, target, requestParam, adapter); + } catch (IOException e) { + throw new EventMeshException(String.format("Request message error, target:%s", target), e); + } + + } + + private void validateCloudEvent(CloudEvent cloudEvent) { + Preconditions.checkNotNull(cloudEvent, "CloudEvent cannot be null"); + } + + private RequestParam buildCommonPostParam(CloudEvent cloudEvent) { + byte[] bodyByte = EventFormatProvider.getInstance().resolveFormat(cloudEvent.getDataContentType()) + .serialize(cloudEvent); + String content = new String(bodyByte, StandardCharsets.UTF_8); + + RequestParam requestParam = new RequestParam(HttpMethod.POST); + requestParam + .addHeader(ProtocolKey.ClientInstanceKey.ENV, eventMeshHttpClientConfig.getEnv()) + .addHeader(ProtocolKey.ClientInstanceKey.IDC, eventMeshHttpClientConfig.getIdc()) + .addHeader(ProtocolKey.ClientInstanceKey.IP, eventMeshHttpClientConfig.getIp()) + .addHeader(ProtocolKey.ClientInstanceKey.PID, eventMeshHttpClientConfig.getPid()) + .addHeader(ProtocolKey.ClientInstanceKey.SYS, eventMeshHttpClientConfig.getSys()) + .addHeader(ProtocolKey.ClientInstanceKey.USERNAME, eventMeshHttpClientConfig.getUserName()) + .addHeader(ProtocolKey.ClientInstanceKey.PASSWD, eventMeshHttpClientConfig.getPassword()) + .addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA) + .addHeader(ProtocolKey.PROTOCOL_TYPE, PROTOCOL_TYPE) + .addHeader(ProtocolKey.PROTOCOL_DESC, PROTOCOL_DESC) + .addHeader(ProtocolKey.PROTOCOL_VERSION, cloudEvent.getSpecVersion().toString()) + + // todo: move producerGroup tp header + .addBody(SendMessageRequestBody.PRODUCERGROUP, eventMeshHttpClientConfig.getProducerGroup()) + .addBody(SendMessageRequestBody.CONTENT, content); + return requestParam; + } + + private CloudEvent enhanceCloudEvent(final CloudEvent cloudEvent) { + return CloudEventBuilder.from(cloudEvent) + .withExtension(ProtocolKey.ClientInstanceKey.ENV, eventMeshHttpClientConfig.getEnv()) + .withExtension(ProtocolKey.ClientInstanceKey.IDC, eventMeshHttpClientConfig.getIdc()) + .withExtension(ProtocolKey.ClientInstanceKey.IP, eventMeshHttpClientConfig.getIp()) + .withExtension(ProtocolKey.ClientInstanceKey.PID, eventMeshHttpClientConfig.getPid()) + .withExtension(ProtocolKey.ClientInstanceKey.SYS, eventMeshHttpClientConfig.getSys()) + .withExtension(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA) + .withExtension(ProtocolKey.PROTOCOL_DESC, cloudEvent.getSpecVersion().name()) + .withExtension(ProtocolKey.PROTOCOL_VERSION, cloudEvent.getSpecVersion().toString()) + .withExtension(ProtocolKey.ClientInstanceKey.BIZSEQNO, RandomStringUtils.generateNum(30)) + .withExtension(ProtocolKey.ClientInstanceKey.UNIQUEID, RandomStringUtils.generateNum(30)) + .build(); + } + + private CloudEvent transformMessage(EventMeshRetObj retObj) { + SendMessageResponseBody.ReplyMessage replyMessage = JsonUtils.deserialize(retObj.getRetMsg(), + SendMessageResponseBody.ReplyMessage.class); + // todo: deserialize message + return null; + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/EventMeshHttpProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/EventMeshHttpProducer.java new file mode 100644 index 0000000000..1077427535 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/EventMeshHttpProducer.java @@ -0,0 +1,89 @@ +/* + * Licensed 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.eventmesh.client.http.producer; + +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.common.EventMeshMessage; +import org.apache.eventmesh.common.exception.EventMeshException; + +import io.cloudevents.CloudEvent; +import io.openmessaging.api.Message; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class EventMeshHttpProducer implements AutoCloseable { + + private final EventMeshMessageProducer eventMeshMessageProducer; + private final CloudEventProducer cloudEventProducer; + private final OpenMessageProducer openMessageProducer; + + public EventMeshHttpProducer(final EventMeshHttpClientConfig eventMeshHttpClientConfig) throws EventMeshException { + this.cloudEventProducer = new CloudEventProducer(eventMeshHttpClientConfig); + this.eventMeshMessageProducer = new EventMeshMessageProducer(eventMeshHttpClientConfig); + this.openMessageProducer = new OpenMessageProducer(eventMeshHttpClientConfig); + } + + public void publish(final EventMeshMessage message) throws EventMeshException { + eventMeshMessageProducer.publish(message); + } + + public void publish(final CloudEvent cloudEvent) throws EventMeshException { + cloudEventProducer.publish(cloudEvent); + } + + public void publish(final Message openMessage) throws EventMeshException { + openMessageProducer.publish(openMessage); + } + + public EventMeshMessage request(final EventMeshMessage message, final long timeout) throws EventMeshException { + return eventMeshMessageProducer.request(message, timeout); + } + + public CloudEvent request(final CloudEvent cloudEvent, final long timeout) throws EventMeshException { + return cloudEventProducer.request(cloudEvent, timeout); + } + + public Message request(final Message openMessage, final long timeout) throws EventMeshException { + return openMessageProducer.request(openMessage, timeout); + } + + public void request(final EventMeshMessage message, final RRCallback rrCallback, final long timeout) + throws EventMeshException { + eventMeshMessageProducer.request(message, rrCallback, timeout); + } + + public void request(final CloudEvent cloudEvent, final RRCallback rrCallback, final long timeout) + throws EventMeshException { + cloudEventProducer.request(cloudEvent, rrCallback, timeout); + } + + public void request(final Message openMessage, final RRCallback rrCallback, final long timeout) + throws EventMeshException { + openMessageProducer.request(openMessage, rrCallback, timeout); + } + + @Override + public void close() throws EventMeshException { + try ( + final EventMeshMessageProducer ignored = eventMeshMessageProducer; + final OpenMessageProducer ignored1 = openMessageProducer; + final CloudEventProducer ignored2 = cloudEventProducer) { + log.info("Close producer"); + } + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/EventMeshMessageProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/EventMeshMessageProducer.java new file mode 100644 index 0000000000..5f528a376b --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/EventMeshMessageProducer.java @@ -0,0 +1,154 @@ +/* + * Licensed 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.eventmesh.client.http.producer; + +import io.cloudevents.SpecVersion; +import org.apache.eventmesh.client.http.AbstractHttpClient; +import org.apache.eventmesh.client.http.EventMeshRetObj; +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.model.RequestParam; +import org.apache.eventmesh.client.http.util.HttpUtils; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.EventMeshMessage; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.utils.JsonUtils; + +import java.io.IOException; + +import com.google.common.base.Preconditions; + +import io.netty.handler.codec.http.HttpMethod; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class EventMeshMessageProducer extends AbstractHttpClient implements EventMeshProtocolProducer { + + private static final String PROTOCOL_TYPE = "eventmeshmessage"; + + private static final String PROTOCOL_DESC = "http"; + + public EventMeshMessageProducer(EventMeshHttpClientConfig eventMeshHttpClientConfig) throws EventMeshException { + super(eventMeshHttpClientConfig); + } + + @Override + public void publish(EventMeshMessage message) throws EventMeshException { + validateEventMeshMessage(message); + RequestParam requestParam = buildCommonPostParam(message) + .addHeader(ProtocolKey.REQUEST_CODE, RequestCode.MSG_SEND_ASYNC.getRequestCode()); + + String target = selectEventMesh(); + try { + String response = HttpUtils.post(httpClient, target, requestParam); + EventMeshRetObj ret = JsonUtils.deserialize(response, EventMeshRetObj.class); + + if (ret.getRetCode() != EventMeshRetCode.SUCCESS.getRetCode()) { + throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); + } + } catch (Exception exception) { + throw new EventMeshException(String.format("Publish message error, target:%s", target), exception); + } + } + + @Override + public EventMeshMessage request(EventMeshMessage message, long timeout) throws EventMeshException { + validateEventMeshMessage(message); + RequestParam requestParam = buildCommonPostParam(message) + .addHeader(ProtocolKey.REQUEST_CODE, RequestCode.MSG_SEND_SYNC.getRequestCode()) + .setTimeout(timeout); + + String target = selectEventMesh(); + + try { + String response = HttpUtils.post(httpClient, target, requestParam); + EventMeshRetObj ret = JsonUtils.deserialize(response, EventMeshRetObj.class); + if (ret.getRetCode() == EventMeshRetCode.SUCCESS.getRetCode()) { + return transformMessage(ret); + } + throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); + } catch (Exception e) { + throw new EventMeshException(String.format("Request message error, target:%s", target), e); + } + } + + @Override + public void request(EventMeshMessage message, RRCallback rrCallback, long timeout) + throws EventMeshException { + validateEventMeshMessage(message); + + RequestParam requestParam = buildCommonPostParam(message) + .addHeader(ProtocolKey.REQUEST_CODE, RequestCode.MSG_SEND_SYNC.getRequestCode()) + .setTimeout(timeout); + + String target = selectEventMesh(); + RRCallbackResponseHandlerAdapter adapter = + new RRCallbackResponseHandlerAdapter<>(message, rrCallback, timeout); + try { + HttpUtils.post(httpClient, null, target, requestParam, adapter); + } catch (IOException e) { + throw new EventMeshException(String.format("Request message error, target:%s", target), e); + } + } + + private void validateEventMeshMessage(EventMeshMessage message) { + Preconditions.checkNotNull(message, "eventMeshMessage invalid"); + Preconditions.checkNotNull(message.getTopic(), "eventMeshMessage[topic] invalid"); + Preconditions.checkNotNull(message.getContent(), "eventMeshMessage[content] invalid"); + } + + private RequestParam buildCommonPostParam(EventMeshMessage message) { + RequestParam requestParam = new RequestParam(HttpMethod.POST); + requestParam + .addHeader(ProtocolKey.ClientInstanceKey.ENV, eventMeshHttpClientConfig.getEnv()) + .addHeader(ProtocolKey.ClientInstanceKey.IDC, eventMeshHttpClientConfig.getIdc()) + .addHeader(ProtocolKey.ClientInstanceKey.IP, eventMeshHttpClientConfig.getIp()) + .addHeader(ProtocolKey.ClientInstanceKey.PID, eventMeshHttpClientConfig.getPid()) + .addHeader(ProtocolKey.ClientInstanceKey.SYS, eventMeshHttpClientConfig.getSys()) + .addHeader(ProtocolKey.ClientInstanceKey.USERNAME, eventMeshHttpClientConfig.getUserName()) + .addHeader(ProtocolKey.ClientInstanceKey.PASSWD, eventMeshHttpClientConfig.getPassword()) + .addHeader(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()) + .addHeader(ProtocolKey.PROTOCOL_TYPE, PROTOCOL_TYPE) + .addHeader(ProtocolKey.PROTOCOL_DESC, PROTOCOL_DESC) + //default ce version is 1.0 + .addHeader(ProtocolKey.PROTOCOL_VERSION, SpecVersion.V1.toString()) + .addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA) + .addBody(SendMessageRequestBody.PRODUCERGROUP, eventMeshHttpClientConfig.getProducerGroup()) + // todo: set message to content is better + .addBody(SendMessageRequestBody.TOPIC, message.getTopic()) + .addBody(SendMessageRequestBody.CONTENT, message.getContent()) + .addBody(SendMessageRequestBody.TTL, message.getProp(Constants.EVENTMESH_MESSAGE_CONST_TTL)) + .addBody(SendMessageRequestBody.BIZSEQNO, message.getBizSeqNo()) + .addBody(SendMessageRequestBody.UNIQUEID, message.getUniqueId()); + return requestParam; + } + + private EventMeshMessage transformMessage(EventMeshRetObj retObj) { + SendMessageResponseBody.ReplyMessage replyMessage = JsonUtils.deserialize(retObj.getRetMsg(), + SendMessageResponseBody.ReplyMessage.class); + return EventMeshMessage.builder() + .content(replyMessage.body) + .prop(replyMessage.properties) + .topic(replyMessage.topic).build(); + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/EventMeshProtocolProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/EventMeshProtocolProducer.java new file mode 100644 index 0000000000..1a0001e2cd --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/EventMeshProtocolProducer.java @@ -0,0 +1,39 @@ +/* + * Licensed 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.eventmesh.client.http.producer; + +import org.apache.eventmesh.common.exception.EventMeshException; + +/** + * EventMeshProducer, SDK should implement this interface. + *

    + *
  • {@link EventMeshProtocolProducer}
  • + *
  • {@link OpenMessageProducer}
  • + *
  • {@link CloudEventProducer}
  • + *
+ */ +public interface EventMeshProtocolProducer extends AutoCloseable { + + void publish(ProtocolMessage eventMeshMessage) throws EventMeshException; + + ProtocolMessage request(ProtocolMessage message, long timeout) throws EventMeshException; + + void request(ProtocolMessage message, RRCallback rrCallback, long timeout) + throws EventMeshException; + +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/LiteProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/LiteProducer.java deleted file mode 100644 index 376e6e6de1..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/LiteProducer.java +++ /dev/null @@ -1,245 +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 org.apache.eventmesh.client.http.producer; - -import org.apache.eventmesh.client.http.AbstractLiteClient; -import org.apache.eventmesh.client.http.EventMeshRetObj; -import org.apache.eventmesh.client.http.conf.LiteClientConfig; -import org.apache.eventmesh.client.http.http.HttpUtil; -import org.apache.eventmesh.client.http.http.RequestParam; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.EventMeshException; -import org.apache.eventmesh.common.LiteMessage; -import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; -import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; -import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; -import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; -import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; -import org.apache.eventmesh.common.protocol.http.common.RequestCode; -import org.apache.eventmesh.common.utils.JsonUtils; - -import org.apache.commons.lang3.ObjectUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.impl.client.CloseableHttpClient; - -import java.util.concurrent.atomic.AtomicBoolean; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Preconditions; - -import io.netty.handler.codec.http.HttpMethod; - -public class LiteProducer extends AbstractLiteClient { - - public Logger logger = LoggerFactory.getLogger(LiteProducer.class); - - public LiteProducer(LiteClientConfig liteClientConfig) { - super(liteClientConfig); - } - - private AtomicBoolean started = new AtomicBoolean(Boolean.FALSE); - - @Override - public void start() throws Exception { - Preconditions.checkState(liteClientConfig != null, "liteClientConfig can't be null"); - Preconditions.checkState(liteClientConfig.getLiteEventMeshAddr() != null, - "liteClientConfig.liteServerAddr can't be null"); - if (started.get()) { - return; - } - logger.info("LiteProducer starting"); - super.start(); - started.compareAndSet(false, true); - logger.info("LiteProducer started"); - } - - @Override - public void shutdown() throws Exception { - if (!started.get()) { - return; - } - logger.info("LiteProducer shutting down"); - super.shutdown(); - started.compareAndSet(true, false); - logger.info("LiteProducer shutdown"); - } - - public AtomicBoolean getStarted() { - return started; - } - - public boolean publish(LiteMessage message) throws Exception { - if (!started.get()) { - start(); - } - Preconditions.checkState(StringUtils.isNotBlank(message.getTopic()), - "eventMeshMessage[topic] invalid"); - Preconditions.checkState(StringUtils.isNotBlank(message.getContent()), - "eventMeshMessage[content] invalid"); - RequestParam requestParam = new RequestParam(HttpMethod.POST); - requestParam.addHeader(ProtocolKey.REQUEST_CODE, - String.valueOf(RequestCode.MSG_SEND_ASYNC.getRequestCode())) - .addHeader(ProtocolKey.ClientInstanceKey.ENV, liteClientConfig.getEnv()) - .addHeader(ProtocolKey.ClientInstanceKey.IDC, liteClientConfig.getIdc()) - .addHeader(ProtocolKey.ClientInstanceKey.IP, liteClientConfig.getIp()) - .addHeader(ProtocolKey.ClientInstanceKey.PID, liteClientConfig.getPid()) - .addHeader(ProtocolKey.ClientInstanceKey.SYS, liteClientConfig.getSys()) - .addHeader(ProtocolKey.ClientInstanceKey.USERNAME, liteClientConfig.getUserName()) - .addHeader(ProtocolKey.ClientInstanceKey.PASSWD, liteClientConfig.getPassword()) - .addHeader(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()) - .addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA) - .setTimeout(Constants.DEFAULT_HTTP_TIME_OUT) - .addBody(SendMessageRequestBody.PRODUCERGROUP, liteClientConfig.getProducerGroup()) - .addBody(SendMessageRequestBody.TOPIC, message.getTopic()) - .addBody(SendMessageRequestBody.CONTENT, message.getContent()) - .addBody(SendMessageRequestBody.TTL, - message.getPropKey(Constants.EVENTMESH_MESSAGE_CONST_TTL)) - .addBody(SendMessageRequestBody.BIZSEQNO, message.getBizSeqNo()) - .addBody(SendMessageRequestBody.UNIQUEID, message.getUniqueId()); - - long startTime = System.currentTimeMillis(); - String target = selectEventMesh(); - String res = ""; - - try (CloseableHttpClient httpClient = setHttpClient()) { - res = HttpUtil.post(httpClient, target, requestParam); - } - - if (logger.isDebugEnabled()) { - logger.debug("publish async message, targetEventMesh:{}, cost:{}ms, message:{}, rtn:{}", - target, System.currentTimeMillis() - startTime, message, res); - } - - EventMeshRetObj ret = JsonUtils.deserialize(res, EventMeshRetObj.class); - - if (ret.getRetCode() == EventMeshRetCode.SUCCESS.getRetCode()) { - return Boolean.TRUE; - } else { - throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); - } - } - - public String selectEventMesh() { - if (liteClientConfig.isUseTls()) { - return Constants.HTTPS_PROTOCOL_PREFIX + eventMeshServerSelector.select(); - } else { - return Constants.HTTP_PROTOCOL_PREFIX + eventMeshServerSelector.select(); - } - } - - public LiteMessage request(LiteMessage message, long timeout) throws Exception { - if (!started.get()) { - start(); - } - Preconditions.checkState(StringUtils.isNotBlank(message.getTopic()), - "eventMeshMessage[topic] invalid"); - Preconditions.checkState(StringUtils.isNotBlank(message.getContent()), - "eventMeshMessage[content] invalid"); - RequestParam requestParam = new RequestParam(HttpMethod.POST); - requestParam.addHeader(ProtocolKey.REQUEST_CODE, - String.valueOf(RequestCode.MSG_SEND_SYNC.getRequestCode())) - .addHeader(ProtocolKey.ClientInstanceKey.ENV, liteClientConfig.getEnv()) - .addHeader(ProtocolKey.ClientInstanceKey.IDC, liteClientConfig.getIdc()) - .addHeader(ProtocolKey.ClientInstanceKey.IP, liteClientConfig.getIp()) - .addHeader(ProtocolKey.ClientInstanceKey.PID, liteClientConfig.getPid()) - .addHeader(ProtocolKey.ClientInstanceKey.SYS, liteClientConfig.getSys()) - .addHeader(ProtocolKey.ClientInstanceKey.USERNAME, liteClientConfig.getUserName()) - .addHeader(ProtocolKey.ClientInstanceKey.PASSWD, liteClientConfig.getPassword()) - .addHeader(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()) - .addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA) - .setTimeout(timeout) - .addBody(SendMessageRequestBody.PRODUCERGROUP, liteClientConfig.getProducerGroup()) - .addBody(SendMessageRequestBody.TOPIC, message.getTopic()) - .addBody(SendMessageRequestBody.CONTENT, message.getContent()) - .addBody(SendMessageRequestBody.TTL, String.valueOf(timeout)) - .addBody(SendMessageRequestBody.BIZSEQNO, message.getBizSeqNo()) - .addBody(SendMessageRequestBody.UNIQUEID, message.getUniqueId()); - - long startTime = System.currentTimeMillis(); - String target = selectEventMesh(); - String res = ""; - - try (CloseableHttpClient httpClient = setHttpClient()) { - res = HttpUtil.post(httpClient, target, requestParam); - } - - if (logger.isDebugEnabled()) { - logger.debug( - "publish sync message by await, targetEventMesh:{}, cost:{}ms, message:{}, rtn:{}", - target, System.currentTimeMillis() - startTime, message, res); - } - - EventMeshRetObj ret = JsonUtils.deserialize(res, EventMeshRetObj.class); - if (ret.getRetCode() == EventMeshRetCode.SUCCESS.getRetCode()) { - LiteMessage eventMeshMessage = new LiteMessage(); - SendMessageResponseBody.ReplyMessage replyMessage = - JsonUtils.deserialize(ret.getRetMsg(), SendMessageResponseBody.ReplyMessage.class); - eventMeshMessage.setContent(replyMessage.body).setProp(replyMessage.properties) - .setTopic(replyMessage.topic); - return eventMeshMessage; - } - - return null; - } - - public void request(LiteMessage message, RRCallback rrCallback, long timeout) throws Exception { - if (!started.get()) { - start(); - } - Preconditions.checkState(StringUtils.isNotBlank(message.getTopic()), - "eventMeshMessage[topic] invalid"); - Preconditions.checkState(StringUtils.isNotBlank(message.getContent()), - "eventMeshMessage[content] invalid"); - Preconditions.checkState(ObjectUtils.allNotNull(rrCallback), - "rrCallback invalid"); - RequestParam requestParam = new RequestParam(HttpMethod.POST); - requestParam.addHeader(ProtocolKey.REQUEST_CODE, - String.valueOf(RequestCode.MSG_SEND_SYNC.getRequestCode())) - .addHeader(ProtocolKey.ClientInstanceKey.ENV, liteClientConfig.getEnv()) - .addHeader(ProtocolKey.ClientInstanceKey.IDC, liteClientConfig.getIdc()) - .addHeader(ProtocolKey.ClientInstanceKey.IP, liteClientConfig.getIp()) - .addHeader(ProtocolKey.ClientInstanceKey.PID, liteClientConfig.getPid()) - .addHeader(ProtocolKey.ClientInstanceKey.SYS, liteClientConfig.getSys()) - .addHeader(ProtocolKey.ClientInstanceKey.USERNAME, liteClientConfig.getUserName()) - .addHeader(ProtocolKey.ClientInstanceKey.PASSWD, liteClientConfig.getPassword()) - .addHeader(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()) - .addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA) - .setTimeout(timeout) - .addBody(SendMessageRequestBody.PRODUCERGROUP, liteClientConfig.getProducerGroup()) - .addBody(SendMessageRequestBody.TOPIC, message.getTopic()) - .addBody(SendMessageRequestBody.CONTENT, message.getContent()) - .addBody(SendMessageRequestBody.TTL, String.valueOf(timeout)) - .addBody(SendMessageRequestBody.BIZSEQNO, message.getBizSeqNo()) - .addBody(SendMessageRequestBody.UNIQUEID, message.getUniqueId()); - - long startTime = System.currentTimeMillis(); - String target = selectEventMesh(); - - try (CloseableHttpClient httpClient = setHttpClient()) { - HttpUtil.post(httpClient, null, target, requestParam, - new RRCallbackResponseHandlerAdapter(message, rrCallback, timeout)); - } - - if (logger.isDebugEnabled()) { - logger.debug("publish sync message by async, target:{}, cost:{}, message:{}", target, - System.currentTimeMillis() - startTime, message); - } - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/OpenMessageProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/OpenMessageProducer.java new file mode 100644 index 0000000000..c0cc127f71 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/OpenMessageProducer.java @@ -0,0 +1,133 @@ +/* + * Licensed 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.eventmesh.client.http.producer; + +import org.apache.eventmesh.client.http.AbstractHttpClient; +import org.apache.eventmesh.client.http.EventMeshRetObj; +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.model.RequestParam; +import org.apache.eventmesh.client.http.util.HttpUtils; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.utils.JsonUtils; + +import java.io.IOException; + +import com.google.common.base.Preconditions; + +import io.netty.handler.codec.http.HttpMethod; +import io.openmessaging.api.Message; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class OpenMessageProducer extends AbstractHttpClient implements EventMeshProtocolProducer { + + private static final String PROTOCOL_TYPE = "openmessage"; + + private static final String PROTOCOL_DESC = "http"; + + public OpenMessageProducer(EventMeshHttpClientConfig eventMeshHttpClientConfig) + throws EventMeshException { + super(eventMeshHttpClientConfig); + } + + @Override + public void publish(Message openMessage) throws EventMeshException { + validateOpenMessage(openMessage); + RequestParam requestParam = buildCommonPostParam(openMessage) + .addHeader(ProtocolKey.REQUEST_CODE, RequestCode.MSG_SEND_ASYNC.getRequestCode()); + String target = selectEventMesh(); + try { + String response = HttpUtils.post(httpClient, target, requestParam); + EventMeshRetObj ret = JsonUtils.deserialize(response, EventMeshRetObj.class); + + if (ret.getRetCode() != EventMeshRetCode.SUCCESS.getRetCode()) { + throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); + } + } catch (Exception exception) { + throw new EventMeshException(String.format("Publish message error, target:%s", target), exception); + } + } + + @Override + public Message request(Message message, long timeout) throws EventMeshException { + validateOpenMessage(message); + RequestParam requestParam = buildCommonPostParam(message) + .addHeader(ProtocolKey.REQUEST_CODE, RequestCode.MSG_SEND_SYNC.getRequestCode()) + .setTimeout(timeout); + String target = selectEventMesh(); + + try { + String response = HttpUtils.post(httpClient, target, requestParam); + EventMeshRetObj ret = JsonUtils.deserialize(response, EventMeshRetObj.class); + if (ret.getRetCode() == EventMeshRetCode.SUCCESS.getRetCode()) { + return transformMessage(ret); + } + throw new EventMeshException(ret.getRetCode(), ret.getRetMsg()); + } catch (Exception e) { + throw new EventMeshException(String.format("Request message error, target:%s", target), e); + } + } + + @Override + public void request(Message message, RRCallback rrCallback, long timeout) throws EventMeshException { + validateOpenMessage(message); + RequestParam requestParam = buildCommonPostParam(message) + .addHeader(ProtocolKey.REQUEST_CODE, RequestCode.MSG_SEND_SYNC.getRequestCode()) + .setTimeout(timeout); + String target = selectEventMesh(); + RRCallbackResponseHandlerAdapter adapter = + new RRCallbackResponseHandlerAdapter<>(message, rrCallback, timeout); + try { + HttpUtils.post(httpClient, null, target, requestParam, adapter); + } catch (IOException e) { + throw new EventMeshException(String.format("Request message error, target:%s", target), e); + } + } + + private void validateOpenMessage(Message openMessage) { + Preconditions.checkNotNull(openMessage, "Message cannot be null"); + } + + private RequestParam buildCommonPostParam(Message openMessage) { + RequestParam requestParam = new RequestParam(HttpMethod.POST); + requestParam + .addHeader(ProtocolKey.ClientInstanceKey.USERNAME, eventMeshHttpClientConfig.getUserName()) + .addHeader(ProtocolKey.ClientInstanceKey.PASSWD, eventMeshHttpClientConfig.getPassword()) + .addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA) + .addHeader(ProtocolKey.PROTOCOL_TYPE, PROTOCOL_TYPE) + .addHeader(ProtocolKey.PROTOCOL_DESC, PROTOCOL_DESC) + // todo: add producerGroup to header, set protocol type, protocol version + .addBody(SendMessageRequestBody.PRODUCERGROUP, eventMeshHttpClientConfig.getProducerGroup()) + .addBody(SendMessageRequestBody.CONTENT, JsonUtils.serialize(openMessage)); + return requestParam; + } + + private Message transformMessage(EventMeshRetObj retObj) { + SendMessageResponseBody.ReplyMessage replyMessage = JsonUtils.deserialize(retObj.getRetMsg(), + SendMessageResponseBody.ReplyMessage.class); + // todo: deserialize message + return null; + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallback.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallback.java index c5187984de..08470961a2 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallback.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallback.java @@ -17,12 +17,17 @@ package org.apache.eventmesh.client.http.producer; +/** + * ProtocolMessage can be + *
    + *
  • {@link org.apache.eventmesh.common.EventMeshMessage}
  • + *
  • {@link io.cloudevents.CloudEvent}
  • + *
  • {@link io.openmessaging.api.Message}
  • + *
+ */ +public interface RRCallback { -import org.apache.eventmesh.common.LiteMessage; - -public interface RRCallback { - - void onSuccess(LiteMessage liteMessage); + void onSuccess(ProtocolMessage protocolMessage); void onException(Throwable e); diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallbackResponseHandlerAdapter.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallbackResponseHandlerAdapter.java index 1dcefe59ec..25237da861 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallbackResponseHandlerAdapter.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallbackResponseHandlerAdapter.java @@ -19,89 +19,90 @@ import org.apache.eventmesh.client.http.EventMeshRetObj; import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.EventMeshException; -import org.apache.eventmesh.common.LiteMessage; +import org.apache.eventmesh.common.EventMeshMessage; +import org.apache.eventmesh.common.exception.EventMeshException; import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.ResponseHandler; import org.apache.http.util.EntityUtils; import java.io.IOException; import java.nio.charset.Charset; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.google.common.base.Preconditions; + +import io.cloudevents.CloudEvent; +import io.openmessaging.api.Message; +import lombok.extern.slf4j.Slf4j; /** * RRCallbackResponseHandlerAdapter. */ -public class RRCallbackResponseHandlerAdapter implements ResponseHandler { - - public Logger logger = LoggerFactory.getLogger(RRCallbackResponseHandlerAdapter.class); +@Slf4j +public class RRCallbackResponseHandlerAdapter implements ResponseHandler { - private long createTime; + private final long createTime; - private LiteMessage liteMessage; + private final ProtocolMessage protocolMessage; - private RRCallback rrCallback; + private final RRCallback rrCallback; - private long timeout; + private final long timeout; - public RRCallbackResponseHandlerAdapter(LiteMessage liteMessage, RRCallback rrCallback, + public RRCallbackResponseHandlerAdapter(ProtocolMessage protocolMessage, RRCallback rrCallback, long timeout) { - this.liteMessage = liteMessage; + Preconditions.checkNotNull(rrCallback, "rrCallback invalid"); + Preconditions.checkNotNull(protocolMessage, "message invalid"); + if (!(protocolMessage instanceof EventMeshMessage) && !(protocolMessage instanceof CloudEvent) + && !(protocolMessage instanceof Message)) { + throw new IllegalArgumentException(String.format("ProtocolMessage: %s is not supported", protocolMessage)); + } + this.protocolMessage = protocolMessage; this.rrCallback = rrCallback; this.timeout = timeout; this.createTime = System.currentTimeMillis(); } @Override - public String handleResponse(HttpResponse response) - throws ClientProtocolException, IOException { + public String handleResponse(HttpResponse response) throws IOException { if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { rrCallback.onException(new EventMeshException(response.toString())); return response.toString(); } if (System.currentTimeMillis() - createTime > timeout) { - String err = String.format( - "response too late, bizSeqNo=%s, uniqueId=%s, createTime=%s, ttl=%s, cost=%sms", - liteMessage.getBizSeqNo(), - liteMessage.getUniqueId(), - DateFormatUtils.format(createTime, Constants.DATE_FORMAT), - timeout, - System.currentTimeMillis() - createTime); - logger.warn(err); + String err = String.format("response too late, message: %s", protocolMessage); rrCallback.onException(new EventMeshException(err)); return err; } - String res = - EntityUtils.toString(response.getEntity(), Charset.forName(Constants.DEFAULT_CHARSET)); + String res = EntityUtils.toString(response.getEntity(), Charset.forName(Constants.DEFAULT_CHARSET)); EventMeshRetObj ret = JsonUtils.deserialize(res, EventMeshRetObj.class); if (ret.getRetCode() != EventMeshRetCode.SUCCESS.getRetCode()) { rrCallback.onException(new EventMeshException(ret.getRetCode(), ret.getRetMsg())); return res; } - LiteMessage liteMessage = new LiteMessage(); - try { - SendMessageResponseBody.ReplyMessage replyMessage = - JsonUtils.deserialize(ret.getRetMsg(), SendMessageResponseBody.ReplyMessage.class); - liteMessage.setContent(replyMessage.body).setProp(replyMessage.properties) - .setTopic(replyMessage.topic); - rrCallback.onSuccess(liteMessage); - } catch (Exception ex) { - rrCallback.onException(new EventMeshException(ex)); - return ex.toString(); - } + // todo: constructor protocol message + ProtocolMessage protocolMessage = transformToProtocolMessage(ret); + rrCallback.onSuccess(protocolMessage); + + return protocolMessage.toString(); + } - return liteMessage.toString(); + private ProtocolMessage transformToProtocolMessage(EventMeshRetObj ret) { + // todo: constructor other protocol message, can judge by protocol type in properties + SendMessageResponseBody.ReplyMessage replyMessage = JsonUtils.deserialize(ret.getRetMsg(), + SendMessageResponseBody.ReplyMessage.class); + EventMeshMessage eventMeshMessage = EventMeshMessage.builder() + .content(replyMessage.body) + .prop(replyMessage.properties) + .topic(replyMessage.topic) + .build(); + return (ProtocolMessage) eventMeshMessage; } } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/util/HttpLoadBalanceUtils.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/util/HttpLoadBalanceUtils.java index 5db7e5415b..d2a779e518 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/util/HttpLoadBalanceUtils.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/util/HttpLoadBalanceUtils.java @@ -19,8 +19,9 @@ import com.google.common.base.Splitter; import org.apache.commons.collections4.CollectionUtils; -import org.apache.eventmesh.client.http.conf.LiteClientConfig; -import org.apache.eventmesh.common.EventMeshException; + +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.common.exception.EventMeshException; import org.apache.eventmesh.common.loadbalance.LoadBalanceSelector; import org.apache.eventmesh.common.loadbalance.RandomLoadBalanceSelector; import org.apache.eventmesh.common.loadbalance.Weight; @@ -36,18 +37,22 @@ public class HttpLoadBalanceUtils { private static final Pattern IP_PORT_PATTERN = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}:\\d{4,5}"); private static final Pattern IP_PORT_WEIGHT_PATTERN = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}:\\d{4,5}:\\d{1,6}"); - public static LoadBalanceSelector createEventMeshServerLoadBalanceSelector(LiteClientConfig liteClientConfig) + public static LoadBalanceSelector createEventMeshServerLoadBalanceSelector( + EventMeshHttpClientConfig eventMeshHttpClientConfig) throws EventMeshException { LoadBalanceSelector eventMeshServerSelector = null; - switch (liteClientConfig.getLoadBalanceType()) { + switch (eventMeshHttpClientConfig.getLoadBalanceType()) { case RANDOM: - eventMeshServerSelector = new RandomLoadBalanceSelector<>(buildClusterGroupFromConfig(liteClientConfig)); + eventMeshServerSelector = new RandomLoadBalanceSelector<>(buildClusterGroupFromConfig( + eventMeshHttpClientConfig)); break; case WEIGHT_RANDOM: - eventMeshServerSelector = new WeightRandomLoadBalanceSelector<>(buildWeightedClusterGroupFromConfig(liteClientConfig)); + eventMeshServerSelector = new WeightRandomLoadBalanceSelector<>(buildWeightedClusterGroupFromConfig( + eventMeshHttpClientConfig)); break; case WEIGHT_ROUND_ROBIN: - eventMeshServerSelector = new WeightRoundRobinLoadBalanceSelector<>(buildWeightedClusterGroupFromConfig(liteClientConfig)); + eventMeshServerSelector = new WeightRoundRobinLoadBalanceSelector<>(buildWeightedClusterGroupFromConfig( + eventMeshHttpClientConfig)); break; default: // ignore @@ -58,9 +63,10 @@ public static LoadBalanceSelector createEventMeshServerLoadBalanceSelect return eventMeshServerSelector; } - private static List> buildWeightedClusterGroupFromConfig(LiteClientConfig liteClientConfig) + private static List> buildWeightedClusterGroupFromConfig( + EventMeshHttpClientConfig eventMeshHttpClientConfig) throws EventMeshException { - List eventMeshAddrs = Splitter.on(";").trimResults().splitToList(liteClientConfig.getLiteEventMeshAddr()); + List eventMeshAddrs = Splitter.on(";").trimResults().splitToList(eventMeshHttpClientConfig.getLiteEventMeshAddr()); if (CollectionUtils.isEmpty(eventMeshAddrs)) { throw new EventMeshException("liteEventMeshAddr can not be empty"); } @@ -69,7 +75,7 @@ private static List> buildWeightedClusterGroupFromConfig(LiteClie for (String eventMeshAddrWight : eventMeshAddrs) { if (!IP_PORT_WEIGHT_PATTERN.matcher(eventMeshAddrWight).matches()) { throw new EventMeshException( - String.format("liteEventMeshAddr:%s is not illegal", liteClientConfig.getLiteEventMeshAddr())); + String.format("liteEventMeshAddr:%s is not illegal", eventMeshHttpClientConfig.getLiteEventMeshAddr())); } int splitIndex = eventMeshAddrWight.lastIndexOf(":"); Weight weight = new Weight<>( @@ -81,9 +87,9 @@ private static List> buildWeightedClusterGroupFromConfig(LiteClie return eventMeshAddrWeightList; } - private static List buildClusterGroupFromConfig(LiteClientConfig liteClientConfig) + private static List buildClusterGroupFromConfig(EventMeshHttpClientConfig eventMeshHttpClientConfig) throws EventMeshException { - List eventMeshAddrs = Splitter.on(";").trimResults().splitToList(liteClientConfig.getLiteEventMeshAddr()); + List eventMeshAddrs = Splitter.on(";").trimResults().splitToList(eventMeshHttpClientConfig.getLiteEventMeshAddr()); if (CollectionUtils.isEmpty(eventMeshAddrs)) { throw new EventMeshException("liteEventMeshAddr can not be empty"); } @@ -92,7 +98,7 @@ private static List buildClusterGroupFromConfig(LiteClientConfig liteCli for (String eventMeshAddr : eventMeshAddrs) { if (!IP_PORT_PATTERN.matcher(eventMeshAddr).matches()) { throw new EventMeshException( - String.format("liteEventMeshAddr:%s is not illegal", liteClientConfig.getLiteEventMeshAddr())); + String.format("liteEventMeshAddr:%s is not illegal", eventMeshHttpClientConfig.getLiteEventMeshAddr())); } eventMeshAddrList.add(eventMeshAddr); } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/http/HttpUtil.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/util/HttpUtils.java similarity index 82% rename from eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/http/HttpUtil.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/util/HttpUtils.java index 4093a89ea1..ef3c5ab76c 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/http/HttpUtil.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/util/HttpUtils.java @@ -15,23 +15,13 @@ * limitations under the License. */ -package org.apache.eventmesh.client.http.http; +package org.apache.eventmesh.client.http.util; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import com.google.common.base.Preconditions; - -import io.netty.handler.codec.http.HttpMethod; +import org.apache.eventmesh.client.http.model.RequestParam; +import org.apache.eventmesh.common.Constants; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.common.Constants; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; @@ -43,12 +33,23 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -public class HttpUtil { +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import com.google.common.base.Preconditions; - public static Logger logger = LoggerFactory.getLogger(HttpUtil.class); +import io.netty.handler.codec.http.HttpMethod; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class HttpUtils { public static String post(CloseableHttpClient client, String uri, @@ -58,10 +59,11 @@ public static String post(CloseableHttpClient client, post(client, null, uri, requestParam, new ResponseHandler() { @Override public String handleResponse(HttpResponse response) throws IOException { - responseHolder.response = EntityUtils.toString(response.getEntity(), Charset.forName(Constants.DEFAULT_CHARSET)); + responseHolder.response = + EntityUtils.toString(response.getEntity(), Charset.forName(Constants.DEFAULT_CHARSET)); countDownLatch.countDown(); - if (logger.isDebugEnabled()) { - logger.debug("{}", responseHolder); + if (log.isDebugEnabled()) { + log.debug("{}", responseHolder); } return responseHolder.response; } @@ -84,10 +86,11 @@ public static String post(CloseableHttpClient client, post(client, forwardAgent, uri, requestParam, new ResponseHandler() { @Override public String handleResponse(HttpResponse response) throws IOException { - responseHolder.response = EntityUtils.toString(response.getEntity(), Charset.forName(Constants.DEFAULT_CHARSET)); + responseHolder.response = + EntityUtils.toString(response.getEntity(), Charset.forName(Constants.DEFAULT_CHARSET)); countDownLatch.countDown(); - if (logger.isDebugEnabled()) { - logger.debug("{}", responseHolder); + if (log.isDebugEnabled()) { + log.debug("{}", responseHolder); } return responseHolder.response; } @@ -96,6 +99,7 @@ public String handleResponse(HttpResponse response) throws IOException { try { countDownLatch.await(requestParam.getTimeout(), TimeUnit.MILLISECONDS); } catch (InterruptedException ie) { + // ignore } return responseHolder.response; @@ -105,7 +109,7 @@ public static void post(CloseableHttpClient client, HttpHost forwardAgent, String uri, RequestParam requestParam, - ResponseHandler responseHandler) throws Exception { + ResponseHandler responseHandler) throws IOException { Preconditions.checkState(client != null, "client can't be null"); Preconditions.checkState(StringUtils.isNotBlank(uri), "uri can't be null"); Preconditions.checkState(requestParam != null, "requestParam can't be null"); @@ -133,8 +137,8 @@ public static void post(CloseableHttpClient client, //ttl RequestConfig.Builder configBuilder = RequestConfig.custom(); configBuilder.setSocketTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))) - .setConnectTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))) - .setConnectionRequestTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))); + .setConnectTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))) + .setConnectionRequestTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))); if (forwardAgent != null) { configBuilder.setProxy(forwardAgent); @@ -142,8 +146,8 @@ public static void post(CloseableHttpClient client, httpPost.setConfig(configBuilder.build()); - if (logger.isDebugEnabled()) { - logger.debug("{}", httpPost); + if (log.isDebugEnabled()) { + log.debug("{}", httpPost); } client.execute(httpPost, responseHandler); @@ -176,8 +180,8 @@ public static void get(CloseableHttpClient client, //ttl RequestConfig.Builder configBuilder = RequestConfig.custom(); configBuilder.setSocketTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))) - .setConnectTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))) - .setConnectionRequestTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))); + .setConnectTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))) + .setConnectionRequestTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))); if (forwardAgent != null) { configBuilder.setProxy(forwardAgent); @@ -185,8 +189,8 @@ public static void get(CloseableHttpClient client, httpGet.setConfig(configBuilder.build()); - if (logger.isDebugEnabled()) { - logger.debug("{}", httpGet); + if (log.isDebugEnabled()) { + log.debug("{}", httpGet); } client.execute(httpGet, responseHandler); @@ -200,10 +204,11 @@ public static String get(CloseableHttpClient client, get(client, null, url, requestParam, new ResponseHandler() { @Override public String handleResponse(HttpResponse response) throws IOException { - responseHolder.response = EntityUtils.toString(response.getEntity(), Charset.forName(Constants.DEFAULT_CHARSET)); + responseHolder.response = + EntityUtils.toString(response.getEntity(), Charset.forName(Constants.DEFAULT_CHARSET)); countDownLatch.countDown(); - if (logger.isDebugEnabled()) { - logger.debug("{}", responseHolder); + if (log.isDebugEnabled()) { + log.debug("{}", responseHolder); } return responseHolder.response; } @@ -226,10 +231,11 @@ public static String get(CloseableHttpClient client, get(client, forwardAgent, url, requestParam, new ResponseHandler() { @Override public String handleResponse(HttpResponse response) throws IOException { - responseHolder.response = EntityUtils.toString(response.getEntity(), Charset.forName(Constants.DEFAULT_CHARSET)); + responseHolder.response = + EntityUtils.toString(response.getEntity(), Charset.forName(Constants.DEFAULT_CHARSET)); countDownLatch.countDown(); - if (logger.isDebugEnabled()) { - logger.debug("{}", responseHolder); + if (log.isDebugEnabled()) { + log.debug("{}", responseHolder); } return responseHolder.response; } @@ -243,12 +249,9 @@ public String handleResponse(HttpResponse response) throws IOException { return responseHolder.response; } + @Data public static class ResponseHolder { public String response; - @Override - public String toString() { - return "ResponseHolder=" + response + ""; - } } } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshTCPClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshTCPClient.java new file mode 100644 index 0000000000..a4a7c8d174 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshTCPClient.java @@ -0,0 +1,62 @@ +/* + * Licensed 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.eventmesh.client.tcp; + +import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.SubscriptionMode; +import org.apache.eventmesh.common.protocol.SubscriptionType; +import org.apache.eventmesh.common.protocol.tcp.Package; + +/** + * EventMesh TCP client, used to sub/pub message by tcp. + * You can use {@link EventMeshTCPClientFactory} to create a target client. + * + * @param protocol message type + * @since 1.3.0 + */ +public interface EventMeshTCPClient extends AutoCloseable { + + void init() throws EventMeshException; + + Package rr(ProtocolMessage msg, long timeout) throws EventMeshException; + + void asyncRR(ProtocolMessage msg, AsyncRRCallback callback, long timeout) throws EventMeshException; + + Package publish(ProtocolMessage msg, long timeout) throws EventMeshException; + + void broadcast(ProtocolMessage msg, long timeout) throws EventMeshException; + + void listen() throws EventMeshException; + + void subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) + throws EventMeshException; + + void unsubscribe() throws EventMeshException; + + void registerPubBusiHandler(ReceiveMsgHook handler) throws EventMeshException; + + void registerSubBusiHandler(ReceiveMsgHook handler) throws EventMeshException; + + void close() throws EventMeshException; + + EventMeshTCPPubClient getPubClient(); + + EventMeshTCPSubClient getSubClient(); +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshTCPClientFactory.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshTCPClientFactory.java new file mode 100644 index 0000000000..4291043db3 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshTCPClientFactory.java @@ -0,0 +1,61 @@ +/* + * Licensed 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.eventmesh.client.tcp; + +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.impl.cloudevent.CloudEventTCPClient; +import org.apache.eventmesh.client.tcp.impl.eventmeshmessage.EventMeshMessageTCPClient; +import org.apache.eventmesh.client.tcp.impl.openmessage.OpenMessageTCPClient; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; + +import com.google.common.base.Preconditions; + +import io.cloudevents.CloudEvent; +import io.openmessaging.api.Message; +import lombok.experimental.UtilityClass; + +@UtilityClass +public class EventMeshTCPClientFactory { + + /** + * Create target {@link EventMeshTCPClient}. + * + * @param eventMeshTcpClientConfig client config + * @param protocolMessageClass target message protocol class + * @param target message protocol type + * @return Target client + */ + @SuppressWarnings("unchecked") + public static EventMeshTCPClient createEventMeshTCPClient( + EventMeshTCPClientConfig eventMeshTcpClientConfig, Class protocolMessageClass) { + Preconditions.checkNotNull(protocolMessageClass, "ProtocolMessage type cannot be null"); + Preconditions.checkNotNull(eventMeshTcpClientConfig, "EventMeshTcpClientConfig cannot be null"); + + if (protocolMessageClass.isAssignableFrom(EventMeshMessage.class)) { + return (EventMeshTCPClient) new EventMeshMessageTCPClient(eventMeshTcpClientConfig); + } + if (protocolMessageClass.isAssignableFrom(CloudEvent.class)) { + return (EventMeshTCPClient) new CloudEventTCPClient(eventMeshTcpClientConfig); + } + if (protocolMessageClass.isAssignableFrom(Message.class)) { + return (EventMeshTCPClient) new OpenMessageTCPClient(eventMeshTcpClientConfig); + } + throw new IllegalArgumentException( + String.format("ProtocolMessageClass: %s is not supported", protocolMessageClass)); + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshTCPPubClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshTCPPubClient.java new file mode 100644 index 0000000000..eafe95ec7a --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshTCPPubClient.java @@ -0,0 +1,53 @@ +/* + * Licensed 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.eventmesh.client.tcp; + +import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.tcp.Package; + +/** + * EventMesh TCP publish client. + *
    + *
  • {@link org.apache.eventmesh.client.tcp.impl.cloudevent.CloudEventTCPPubClient}
  • + *
  • {@link org.apache.eventmesh.client.tcp.impl.eventmeshmessage.EventMeshMessageTCPSubClient}
  • + *
  • {@link org.apache.eventmesh.client.tcp.impl.openmessage.OpenMessageTCPPubClient}
  • + *
+ * + * @since 1.3.0 + */ +public interface EventMeshTCPPubClient extends AutoCloseable { + + void init() throws EventMeshException; + + void reconnect() throws EventMeshException; + + // todo: Hide package method, use ProtocolMessage + Package rr(ProtocolMessage event, long timeout) throws EventMeshException; + + void asyncRR(ProtocolMessage event, AsyncRRCallback callback, long timeout) throws EventMeshException; + + Package publish(ProtocolMessage event, long timeout) throws EventMeshException; + + void broadcast(ProtocolMessage event, long timeout) throws EventMeshException; + + void registerBusiHandler(ReceiveMsgHook handler) throws EventMeshException; + + void close() throws EventMeshException; +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshTCPSubClient.java similarity index 54% rename from eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshClient.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshTCPSubClient.java index c98aa7a8b3..0cb2a03f3f 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshClient.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshTCPSubClient.java @@ -17,39 +17,35 @@ package org.apache.eventmesh.client.tcp; -import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; -import org.apache.eventmesh.common.protocol.SubscriptionType; -import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.exception.EventMeshException; import org.apache.eventmesh.common.protocol.SubscriptionMode; +import org.apache.eventmesh.common.protocol.SubscriptionType; -public interface EventMeshClient { - - Package rr(Package msg, long timeout) throws Exception; - - void asyncRR(Package msg, AsyncRRCallback callback, long timeout) throws Exception; - - Package publish(Package msg, long timeout) throws Exception; - - void broadcast(Package msg, long timeout) throws Exception; - - void init() throws Exception; - - void close(); - - void heartbeat() throws Exception; +/** + * EventMesh TCP subscribe client. + *
    + *
  • {@link org.apache.eventmesh.client.tcp.impl.cloudevent.CloudEventTCPSubClient}
  • + *
  • {@link org.apache.eventmesh.client.tcp.impl.eventmeshmessage.EventMeshMessageTCPSubClient}
  • + *
  • {@link org.apache.eventmesh.client.tcp.impl.openmessage.OpenMessageTCPSubClient}
  • + *
+ * + * @since 1.3.0 + */ +public interface EventMeshTCPSubClient extends AutoCloseable { - void listen() throws Exception; + void init() throws EventMeshException; - void subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) throws Exception; + void reconnect() throws EventMeshException; - void unsubscribe() throws Exception; + void subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) + throws EventMeshException; - void registerPubBusiHandler(ReceiveMsgHook handler) throws Exception; + void unsubscribe() throws EventMeshException; - void registerSubBusiHandler(ReceiveMsgHook handler) throws Exception; + void listen() throws EventMeshException; - SimplePubClient getPubClient(); + void registerBusiHandler(ReceiveMsgHook handler) throws EventMeshException; - SimpleSubClient getSubClient(); + void close() throws EventMeshException; } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/SimplePubClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/SimplePubClient.java deleted file mode 100644 index 239cfa423d..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/SimplePubClient.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 org.apache.eventmesh.client.tcp; - - -import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; -import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; - -public interface SimplePubClient { - - void init() throws Exception; - - void close(); - - void heartbeat() throws Exception; - - void reconnect() throws Exception; - - Package rr(Package msg, long timeout) throws Exception; - - void asyncRR(Package msg, AsyncRRCallback callback, long timeout) throws Exception; - - Package publish(Package msg, long timeout) throws Exception; - - void broadcast(Package msg, long timeout) throws Exception; - - void registerBusiHandler(ReceiveMsgHook handler) throws Exception; - - UserAgent getUserAgent(); -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/SimpleSubClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/SimpleSubClient.java deleted file mode 100644 index 3439f208f9..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/SimpleSubClient.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 org.apache.eventmesh.client.tcp; - - -import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; -import org.apache.eventmesh.common.protocol.SubscriptionType; -import org.apache.eventmesh.common.protocol.SubscriptionMode; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; - -public interface SimpleSubClient { - void init() throws Exception; - - void close(); - - void heartbeat() throws Exception; - - void reconnect() throws Exception; - - void subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) throws Exception; - - void unsubscribe() throws Exception; - - void listen() throws Exception; - - void registerBusiHandler(ReceiveMsgHook handler) throws Exception; - - UserAgent getUserAgent(); -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshCommon.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshCommon.java index a3f89e8a82..58b3008b1c 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshCommon.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshCommon.java @@ -19,46 +19,11 @@ public class EventMeshCommon { - /** - * Interval for printing thread pool status - */ - public static int PRINTTHREADPOOLSTATE_INTEVAL = 1; - - /** - * Interval between data reporting to logServer - */ - public static int LOGSERVER_INTEVAL = 1 * 60 * 1000; - /** * CLIENT heartbeat interval */ public static int HEARTBEAT = 30 * 1000; - /** - * Obsolete RR cleanup interval - */ - public static int REQUEST_CONTEXT_CLEAN_EXPIRE = 60 * 1000; - - /** - * Obsolete METRICS cleanup interval - */ - public static int METRICS_CLEAN_EXPIRE = 2 * 1000; - - /** - * Obsolete SESSION cleanup interval - */ - public static int SESSION_CLEAN_EXPIRE = 5 * 1000; - - /** - * Username used for EventMesh verification - */ - public static String EventMesh_USER = ""; - - /** - * Password used for EventMesh verification - */ - public static String EventMesh_PASS = ""; - /** * Timeout time shared by the server */ @@ -74,50 +39,8 @@ public class EventMeshCommon { */ public static String USER_AGENT_PURPOSE_SUB = "sub"; - /** - * Consumer group prefix of clustering consumers - */ - public static String PREFIX_CONSUMER_GROUP_CLUSTERING = "clustering"; - - /** - * Consumer group prefix of broadcasting consumers - */ - public static String PREFIX_CONSUMER_GROUP_BROADCASTING = "broadcast"; - - /** - * The specific IP address and port of the cluster where the RR messages are stored - */ - public static String KEY_RR_REQ_STROE_ADDRESS = "rr_req_store_addr"; - - /** - * MSGID of RR requests stored on WEMQ - */ - public static String KEY_RR_REQ_WEMQ_MSG_ID = "rr_req_wemq_msg_id"; - - /** - * If messages in multiple TOPICs are bypass messages, they will all be sent to C according to this TOPIC. If C - * matches this bq-bypass, it will be considered as bypass, and it will be parsed by bypass. - */ - public static String KEY_BYPASS_MSG_ORIGINAL_TOPIC = "original_topic"; - - /** - * Identification KEY: Client side queries server-level statistics of the server - */ - public static String KEY_QUERY_SERVER_STATISTICS = "server-statistic"; - - /** - * Identification KEY: Client side queries session-level statistics of the server - */ - public static String KEY_QUERY_SESSION_STATISTICS = "session-statistic"; - - /** - * Used to count SESSION TPS. Use prefixes to distinguish TPS of different types of messages. - */ - public static String PREFIX_SESSION_TPS_STAT_RRSEND = "rr_send_tps_"; - - public static String PREFIX_SESSION_TPS_STAT_RRREV = "rr_rev_tps_"; - - public static String PREFIX_SESSION_TPS_STAT_EVENTSEND = "event_send_tps_"; - - public static String PREFIX_SESSION_TPS_STAT_EVENTREV = "event_rev_tps_"; + // protocol type + public static String CLOUD_EVENTS_PROTOCOL_NAME = "cloudevents"; + public static String EM_MESSAGE_PROTOCOL_NAME = "eventmeshmessage"; + public static String OPEN_MESSAGE_PROTOCOL_NAME = "openmessage"; } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshThreadFactoryImpl.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshThreadFactoryImpl.java deleted file mode 100644 index 49692baa92..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshThreadFactoryImpl.java +++ /dev/null @@ -1,49 +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 org.apache.eventmesh.client.tcp.common; - -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.atomic.AtomicLong; - -public class EventMeshThreadFactoryImpl implements ThreadFactory { - private final AtomicLong threadIndex = new AtomicLong(0); - private final String threadNamePrefix; - private Boolean isDaemonSpecified = null; - - public EventMeshThreadFactoryImpl(final String threadNamePrefix) { - this.threadNamePrefix = threadNamePrefix; - } - - public EventMeshThreadFactoryImpl(final String threadNamePrefix, final boolean isDaemonSpecified) { - this.threadNamePrefix = threadNamePrefix; - this.isDaemonSpecified = isDaemonSpecified; - } - - public String getThreadNamePrefix() { - return threadNamePrefix; - } - - @Override - public Thread newThread(Runnable r) { - Thread t = new Thread(r, threadNamePrefix + '-' + this.threadIndex.incrementAndGet()); - if (isDaemonSpecified != null) { - t.setDaemon(isDaemonSpecified); - } - return t; - } -} \ No newline at end of file diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/MessageUtils.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/MessageUtils.java index 5b9d5143d5..a6c9eea245 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/MessageUtils.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/MessageUtils.java @@ -17,16 +17,27 @@ package org.apache.eventmesh.client.tcp.common; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.SubscriptionItem; +import org.apache.eventmesh.common.protocol.SubscriptionMode; +import org.apache.eventmesh.common.protocol.SubscriptionType; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; +import org.apache.eventmesh.common.protocol.tcp.Header; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.Subscription; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; + import java.util.ArrayList; import java.util.List; import java.util.concurrent.ThreadLocalRandom; -import org.apache.eventmesh.common.protocol.SubscriptionType; -import org.apache.eventmesh.common.protocol.tcp.Subscription; -import org.apache.eventmesh.common.protocol.SubscriptionItem; -import org.apache.eventmesh.common.protocol.SubscriptionMode; -import org.apache.eventmesh.common.protocol.tcp.*; -import org.apache.eventmesh.common.protocol.tcp.Package; +import org.assertj.core.util.Preconditions; + +import io.cloudevents.CloudEvent; +import io.cloudevents.SpecVersion; +import io.cloudevents.core.provider.EventFormatProvider; +import io.openmessaging.api.Message; public class MessageUtils { private static final int seqLength = 10; @@ -56,7 +67,8 @@ public static Package listen() { return msg; } - public static Package subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) { + public static Package subscribe(String topic, SubscriptionMode subscriptionMode, + SubscriptionType subscriptionType) { Package msg = new Package(); msg.setHeader(new Header(Command.SUBSCRIBE_REQUEST, 0, null, generateRandomString(seqLength))); msg.setBody(generateSubscription(topic, subscriptionMode, subscriptionType)); @@ -76,6 +88,35 @@ public static Package asyncMessageAck(Package in) { return msg; } + public static Package buildPackage(Object message, Command command) { + Package msg = new Package(); + msg.setHeader(new Header(command, 0, null, generateRandomString(seqLength))); + if (message instanceof CloudEvent) { + CloudEvent cloudEvent = (CloudEvent) message; + Preconditions.checkNotNull(cloudEvent.getDataContentType(), "DateContentType cannot be null"); + msg.getHeader().putProperty(Constants.PROTOCOL_TYPE, EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME); + msg.getHeader().putProperty(Constants.PROTOCOL_VERSION, cloudEvent.getSpecVersion().toString()); + msg.getHeader().putProperty(Constants.PROTOCOL_DESC, "tcp"); + byte[] bodyByte = EventFormatProvider.getInstance().resolveFormat(cloudEvent.getDataContentType()) + .serialize((CloudEvent) message); + msg.setBody(bodyByte); + } else if (message instanceof EventMeshMessage) { + msg.getHeader().putProperty(Constants.PROTOCOL_TYPE, EventMeshCommon.EM_MESSAGE_PROTOCOL_NAME); + msg.getHeader().putProperty(Constants.PROTOCOL_VERSION, SpecVersion.V1.toString()); + msg.getHeader().putProperty(Constants.PROTOCOL_DESC, "tcp"); + msg.setBody(message); + } else if (message instanceof Message) { + msg.getHeader().putProperty(Constants.PROTOCOL_TYPE, EventMeshCommon.OPEN_MESSAGE_PROTOCOL_NAME); + // todo: this version need to be confirmed. + msg.getHeader().putProperty(Constants.PROTOCOL_VERSION, SpecVersion.V1.toString()); + } else { + // unsupported protocol for server + throw new IllegalArgumentException("Unsupported message protocol"); + } + + return msg; + } + public static Package broadcastMessageAck(Package in) { Package msg = new Package(); msg.setHeader(new Header(Command.BROADCAST_MESSAGE_TO_CLIENT_ACK, 0, null, in.getHeader().getSeq())); @@ -98,41 +139,43 @@ public static Package responseToClientAck(Package in) { } public static UserAgent generateSubClient(UserAgent agent) { - UserAgent user = new UserAgent(); - user.setEnv(agent.getEnv()); - user.setHost(agent.getHost()); - user.setPassword(agent.getPassword()); - user.setUsername(agent.getUsername()); - user.setPath(agent.getPath()); - user.setPort(agent.getPort()); - user.setSubsystem(agent.getSubsystem()); - user.setPid(agent.getPid()); - user.setVersion(agent.getVersion()); - user.setIdc(agent.getIdc()); - user.setConsumerGroup(agent.getConsumerGroup()); - user.setProducerGroup(agent.getProducerGroup()); - user.setPurpose(EventMeshCommon.USER_AGENT_PURPOSE_SUB); - return user; + return UserAgent.builder() + .env(agent.getEnv()) + .host(agent.getHost()) + .password(agent.getPassword()) + .username(agent.getUsername()) + .path(agent.getPath()) + .port(agent.getPort()) + .subsystem(agent.getSubsystem()) + .pid(agent.getPid()) + .version(agent.getVersion()) + .idc(agent.getIdc()) + .consumerGroup(agent.getConsumerGroup()) + .producerGroup(agent.getProducerGroup()) + .purpose(EventMeshCommon.USER_AGENT_PURPOSE_SUB) + .build(); } public static UserAgent generatePubClient(UserAgent agent) { - UserAgent user = new UserAgent(); - user.setEnv(agent.getEnv()); - user.setHost(agent.getHost()); - user.setPassword(agent.getPassword()); - user.setUsername(agent.getUsername()); - user.setPath(agent.getPath()); - user.setPort(agent.getPort()); - user.setSubsystem(agent.getSubsystem()); - user.setPid(agent.getPid()); - user.setVersion(agent.getVersion()); - user.setIdc(agent.getIdc()); - user.setProducerGroup(agent.getProducerGroup()); - user.setPurpose(EventMeshCommon.USER_AGENT_PURPOSE_PUB); - return user; + return UserAgent.builder() + .env(agent.getEnv()) + .host(agent.getHost()) + .password(agent.getPassword()) + .username(agent.getUsername()) + .path(agent.getPath()) + .port(agent.getPort()) + .subsystem(agent.getSubsystem()) + .pid(agent.getPid()) + .version(agent.getVersion()) + .idc(agent.getIdc()) + .consumerGroup(agent.getConsumerGroup()) + .producerGroup(agent.getProducerGroup()) + .purpose(EventMeshCommon.USER_AGENT_PURPOSE_PUB) + .build(); } - private static Subscription generateSubscription(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) { + private static Subscription generateSubscription(String topic, SubscriptionMode subscriptionMode, + SubscriptionType subscriptionType) { Subscription subscription = new Subscription(); List subscriptionItems = new ArrayList<>(); subscriptionItems.add(new SubscriptionItem(topic, subscriptionMode, subscriptionType)); diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/service/CompatibilityChecker.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/PropertyConst.java similarity index 75% rename from eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/service/CompatibilityChecker.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/PropertyConst.java index f9f844781f..bbc14f28d1 100644 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/service/CompatibilityChecker.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/PropertyConst.java @@ -14,11 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.eventmesh.schema.registry.server.service; -import org.apache.eventmesh.schema.registry.server.domain.Schema; +package org.apache.eventmesh.client.tcp.common; -public interface CompatibilityChecker { +/** + * properties key name + */ +public class PropertyConst { + + public static String PROPERTY_MESSAGE_PROTOCOL = "message_protocol"; - boolean isCompatible(Schema schemaA, Schema schemaB); + public static String PROPERTY_CLOUD_EVENT_VERSION = "cloud_event_version"; } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/ReceiveMsgHook.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/ReceiveMsgHook.java index bc60a6a8a2..802f038bb2 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/ReceiveMsgHook.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/ReceiveMsgHook.java @@ -17,9 +17,22 @@ package org.apache.eventmesh.client.tcp.common; -import io.netty.channel.ChannelHandlerContext; -import org.apache.eventmesh.common.protocol.tcp.Package; +import java.util.Optional; + +/** + * ReceiveMsgHook. + * + * @param receive message type. + */ +@FunctionalInterface +public interface ReceiveMsgHook { + + /** + * Handle the received message, return the response message. + * + * @param msg + * @return + */ + Optional handle(ProtocolMessage msg); -public interface ReceiveMsgHook { - void handle(Package msg, ChannelHandlerContext ctx); } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java index 5513e1310e..b31f876688 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java @@ -17,8 +17,12 @@ package org.apache.eventmesh.client.tcp.common; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.common.protocol.tcp.codec.Codec; + import java.io.Closeable; -import java.io.IOException; import java.net.InetSocketAddress; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; @@ -28,6 +32,9 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.ThreadFactoryBuilder; + import io.netty.bootstrap.Bootstrap; import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.AdaptiveRecvByteBufAllocator; @@ -43,65 +50,96 @@ import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; +import lombok.extern.slf4j.Slf4j; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.apache.eventmesh.common.protocol.tcp.codec.Codec; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +@Slf4j public abstract class TcpClient implements Closeable { - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - public int clientNo = (new Random()).nextInt(1000); + public final int clientNo = (new Random()).nextInt(1000); - protected ConcurrentHashMap contexts = new ConcurrentHashMap<>(); + protected final ConcurrentHashMap contexts = new ConcurrentHashMap<>(); - private final String host; - private final int port; + protected final String host; + protected final int port; + protected final UserAgent userAgent; - private Bootstrap bootstrap = new Bootstrap(); + private final Bootstrap bootstrap = new Bootstrap(); - private EventLoopGroup workers = new NioEventLoopGroup(); + private final EventLoopGroup workers = new NioEventLoopGroup(); private Channel channel; - protected static final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(4, new EventMeshThreadFactoryImpl("TCPClientScheduler", true)); + private ScheduledFuture heartTask; - public TcpClient(String host, int port) { - this.host = host; - this.port = port; + protected static final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor( + Runtime.getRuntime().availableProcessors(), + new ThreadFactoryBuilder().setNameFormat("TCPClientScheduler").setDaemon(true).build()); + + public TcpClient(EventMeshTCPClientConfig eventMeshTcpClientConfig) { + Preconditions.checkNotNull(eventMeshTcpClientConfig, "EventMeshTcpClientConfig cannot be null"); + Preconditions.checkNotNull(eventMeshTcpClientConfig.getHost(), "Host cannot be null"); + Preconditions.checkState(eventMeshTcpClientConfig.getPort() > 0, "port is not validated"); + this.host = eventMeshTcpClientConfig.getHost(); + this.port = eventMeshTcpClientConfig.getPort(); + this.userAgent = eventMeshTcpClientConfig.getUserAgent(); } protected synchronized void open(SimpleChannelInboundHandler handler) throws Exception { bootstrap.group(workers); bootstrap.channel(NioSocketChannel.class); bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1_000) - .option(ChannelOption.SO_KEEPALIVE, true) - .option(ChannelOption.SO_SNDBUF, 64 * 1024) - .option(ChannelOption.SO_RCVBUF, 64 * 1024) - .option(ChannelOption.RCVBUF_ALLOCATOR, new AdaptiveRecvByteBufAllocator(1024, 8192, 65536)) - .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); + .option(ChannelOption.SO_KEEPALIVE, true) + .option(ChannelOption.SO_SNDBUF, 64 * 1024) + .option(ChannelOption.SO_RCVBUF, 64 * 1024) + .option(ChannelOption.RCVBUF_ALLOCATOR, new AdaptiveRecvByteBufAllocator(1024, 8192, 65536)) + .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); bootstrap.handler(new ChannelInitializer() { - public void initChannel(SocketChannel ch) throws Exception { + public void initChannel(SocketChannel ch) { ch.pipeline().addLast(new Codec.Encoder(), new Codec.Decoder()) - .addLast(handler, newExceptionHandler()); + .addLast(handler, newExceptionHandler()); } }); ChannelFuture f = bootstrap.connect(host, port).sync(); InetSocketAddress localAddress = (InetSocketAddress) f.channel().localAddress(); channel = f.channel(); - logger.info("connected|local={}:{}|server={}", localAddress.getAddress().getHostAddress(), localAddress.getPort(), host + ":" + port); + log + .info("connected|local={}:{}|server={}", localAddress.getAddress().getHostAddress(), localAddress.getPort(), + host + ":" + port); } @Override - public void close() throws IOException { + public void close() { try { channel.disconnect().sync(); - } catch (InterruptedException e) { - logger.warn("close tcp client failed.|remote address={}", channel.remoteAddress(), e); + workers.shutdownGracefully(); + if (heartTask != null) { + heartTask.cancel(false); + } + goodbye(); + } catch (Exception e) { + Thread.currentThread().interrupt(); + log.warn("close tcp client failed.|remote address={}", channel.remoteAddress(), e); + } + } + + protected void heartbeat() { + if (heartTask == null) { + synchronized (TcpClient.class) { + heartTask = scheduler.scheduleAtFixedRate(() -> { + try { + if (!isActive()) { + reconnect(); + } + Package msg = MessageUtils.heartBeat(); + io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + log.debug("heart beat start {}", msg); + } catch (Exception ignore) { + // ignore + } + }, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS); + } } - workers.shutdownGracefully(); } protected synchronized void reconnect() throws Exception { @@ -117,7 +155,7 @@ protected void send(Package msg) throws Exception { if (channel.isWritable()) { channel.writeAndFlush(msg).addListener((ChannelFutureListener) future -> { if (!future.isSuccess()) { - logger.warn("send msg failed", future.cause()); + log.warn("send msg failed", future.cause()); } }); } else { @@ -132,19 +170,33 @@ protected Package io(Package msg, long timeout) throws Exception { if (!contexts.contains(c)) { contexts.put(key, c); } else { - logger.info("duplicate key : {}", key); + log.info("duplicate key : {}", key); } send(msg); - if (!c.getLatch().await(timeout, TimeUnit.MILLISECONDS)) + if (!c.getLatch().await(timeout, TimeUnit.MILLISECONDS)) { throw new TimeoutException("operation timeout, context.key=" + c.getKey()); + } return c.getResponse(); } + // todo: remove hello + protected void hello() throws Exception { + Package msg = MessageUtils.hello(userAgent); + this.io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + } + + // todo: remove goodbye + protected void goodbye() throws Exception { + Package msg = MessageUtils.goodbye(); + this.io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + } + private ChannelDuplexHandler newExceptionHandler() { return new ChannelDuplexHandler() { @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - logger.info("exceptionCaught, close connection.|remote address={}", ctx.channel().remoteAddress(), cause); + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { + log + .info("exceptionCaught, close connection.|remote address={}", ctx.channel().remoteAddress(), cause); ctx.close(); } }; diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/response/SubjectAndVersionResponse.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/conf/EventMeshTCPClientConfig.java similarity index 75% rename from eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/response/SubjectAndVersionResponse.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/conf/EventMeshTCPClientConfig.java index e582e27d78..56b94f5e52 100644 --- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/response/SubjectAndVersionResponse.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/conf/EventMeshTCPClientConfig.java @@ -14,15 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.eventmesh.schema.registry.server.response; -import lombok.AllArgsConstructor; +package org.apache.eventmesh.client.tcp.conf; + +import org.apache.eventmesh.common.protocol.tcp.UserAgent; + +import lombok.Builder; import lombok.Data; @Data -@AllArgsConstructor -public class SubjectAndVersionResponse { - public String subject; - - public int version; +@Builder +public class EventMeshTCPClientConfig { + private String host; + private int port; + private UserAgent userAgent; } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/AbstractEventMeshTCPPubHandler.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/AbstractEventMeshTCPPubHandler.java new file mode 100644 index 0000000000..4eca20e98f --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/AbstractEventMeshTCPPubHandler.java @@ -0,0 +1,73 @@ +/* + * Licensed 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.eventmesh.client.tcp.impl; + +import org.apache.eventmesh.client.tcp.common.MessageUtils; +import org.apache.eventmesh.client.tcp.common.RequestContext; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.Package; + +import java.util.concurrent.ConcurrentHashMap; + +import com.google.common.base.Preconditions; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public abstract class AbstractEventMeshTCPPubHandler extends SimpleChannelInboundHandler { + + private final ConcurrentHashMap contexts; + + public AbstractEventMeshTCPPubHandler(ConcurrentHashMap contexts) { + this.contexts = contexts; + } + + @Override + protected void channelRead0(ChannelHandlerContext ctx, Package msg) { + log.info("SimplePubClientImpl|receive|msg={}", msg); + + Preconditions.checkNotNull(msg.getHeader(), "Tcp package header cannot be null"); + Command cmd = msg.getHeader().getCmd(); + switch (cmd) { + case RESPONSE_TO_CLIENT: + callback(getMessage(msg), ctx); + sendResponse(MessageUtils.responseToClientAck(msg)); + break; + case SERVER_GOODBYE_REQUEST: + //TODO + break; + default: + break; + + } + RequestContext context = contexts.get(RequestContext._key(msg)); + if (context != null) { + contexts.remove(context.getKey()); + context.finish(msg); + } + } + + public abstract void callback(ProtocolMessage protocolMessage, ChannelHandlerContext ctx); + + public abstract ProtocolMessage getMessage(Package tcpPackage); + + public abstract void sendResponse(Package tcpPackage); + +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/AbstractEventMeshTCPSubHandler.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/AbstractEventMeshTCPSubHandler.java new file mode 100644 index 0000000000..1149e09ad5 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/AbstractEventMeshTCPSubHandler.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.eventmesh.client.tcp.impl; + +import org.apache.eventmesh.client.tcp.common.MessageUtils; +import org.apache.eventmesh.client.tcp.common.RequestContext; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.Package; + +import java.util.concurrent.ConcurrentHashMap; + +import com.google.common.base.Preconditions; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public abstract class AbstractEventMeshTCPSubHandler extends SimpleChannelInboundHandler { + + protected final ConcurrentHashMap contexts; + + public AbstractEventMeshTCPSubHandler(ConcurrentHashMap contexts) { + this.contexts = contexts; + } + + @Override + protected void channelRead0(ChannelHandlerContext ctx, Package msg) throws Exception { + Preconditions.checkNotNull(msg, "TCP package cannot be null"); + Preconditions.checkNotNull(msg.getHeader(), "TCP package header cannot be null"); + Command cmd = msg.getHeader().getCmd(); + log.info("|receive|type={}|msg={}", cmd, msg); + switch (cmd) { + case REQUEST_TO_CLIENT: + callback(getProtocolMessage(msg), ctx); + response(MessageUtils.requestToClientAck(msg)); + break; + case ASYNC_MESSAGE_TO_CLIENT: + callback(getProtocolMessage(msg), ctx); + response(MessageUtils.asyncMessageAck(msg)); + break; + case BROADCAST_MESSAGE_TO_CLIENT: + callback(getProtocolMessage(msg), ctx); + response(MessageUtils.broadcastMessageAck(msg)); + break; + case SERVER_GOODBYE_REQUEST: + // TODO + break; + default: + log.error("msg ignored|{}|{}", cmd, msg); + } + RequestContext context = contexts.get(RequestContext._key(msg)); + if (context != null) { + contexts.remove(context.getKey()); + context.finish(msg); + } else { + log.error("msg ignored,context not found.|{}|{}", cmd, msg); + } + } + + public abstract ProtocolMessage getProtocolMessage(Package tcpPackage); + + public abstract void callback(ProtocolMessage protocolMessage, ChannelHandlerContext ctx); + + public abstract void response(Package tcpPackage); +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/DefaultEventMeshClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/DefaultEventMeshClient.java deleted file mode 100644 index c75922f688..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/DefaultEventMeshClient.java +++ /dev/null @@ -1,130 +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 org.apache.eventmesh.client.tcp.impl; - - -import org.apache.eventmesh.client.tcp.EventMeshClient; -import org.apache.eventmesh.client.tcp.SimplePubClient; -import org.apache.eventmesh.client.tcp.SimpleSubClient; -import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; -import org.apache.eventmesh.client.tcp.common.MessageUtils; -import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; -import org.apache.eventmesh.common.protocol.SubscriptionType; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.apache.eventmesh.common.protocol.SubscriptionMode; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; - -public class DefaultEventMeshClient implements EventMeshClient { - protected UserAgent agent; - private String accessHost; - private int accessPort; - - private SimplePubClient pubClient; - private SimpleSubClient subClient; - - public DefaultEventMeshClient(String accessHost, int accessPort, UserAgent agent) { - this.accessHost = accessHost; - this.accessPort = accessPort; - this.agent = agent; - - UserAgent subAgent = MessageUtils.generateSubClient(agent); - this.subClient = new SimpleSubClientImpl(accessHost, accessPort, subAgent); - - UserAgent pubAgent = MessageUtils.generatePubClient(agent); - this.pubClient = new SimplePubClientImpl(accessHost, accessPort, pubAgent); - } - - public SimplePubClient getPubClient() { - return pubClient; - } - - public void setPubClient(SimplePubClient pubClient) { - this.pubClient = pubClient; - } - - public SimpleSubClient getSubClient() { - return subClient; - } - - public void setSubClient(SimpleSubClient subClient) { - this.subClient = subClient; - } - - public Package rr(Package msg, long timeout) throws Exception { - return this.pubClient.rr(msg, timeout); - } - - public Package publish(Package msg, long timeout) throws Exception { - return this.pubClient.publish(msg, timeout); - } - - public void broadcast(Package msg, long timeout) throws Exception { - this.pubClient.broadcast(msg, timeout); - } - - public void init() throws Exception { - this.subClient.init(); - this.pubClient.init(); - } - - public void close() { - this.pubClient.close(); - this.subClient.close(); - } - - public void heartbeat() throws Exception { - this.pubClient.heartbeat(); - this.subClient.heartbeat(); - } - - public void listen() throws Exception { - this.subClient.listen(); - } - - @Override - public void subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) throws Exception { - this.subClient.subscribe(topic, subscriptionMode, subscriptionType); - } - - @Override - public void unsubscribe() throws Exception { - this.subClient.unsubscribe(); - } - - public void registerSubBusiHandler(ReceiveMsgHook handler) throws Exception { - this.subClient.registerBusiHandler(handler); - } - - @Override - public void asyncRR(Package msg, AsyncRRCallback callback, long timeout) throws Exception { - this.pubClient.asyncRR(msg, callback, timeout); - } - - public void registerPubBusiHandler(ReceiveMsgHook handler) throws Exception { - this.pubClient.registerBusiHandler(handler); - } - - @Override - public String toString() { - return "DefaultEventMeshClient{" + - "accessHost='" + accessHost + '\'' + - ", accessPort=" + accessPort + - ", agent=" + agent + - '}'; - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimplePubClientImpl.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimplePubClientImpl.java deleted file mode 100644 index 0e1f6b57d7..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimplePubClientImpl.java +++ /dev/null @@ -1,194 +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 org.apache.eventmesh.client.tcp.impl; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.SimpleChannelInboundHandler; - -import org.apache.eventmesh.client.tcp.SimplePubClient; -import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; -import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.client.tcp.common.MessageUtils; -import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; -import org.apache.eventmesh.client.tcp.common.RequestContext; -import org.apache.eventmesh.client.tcp.common.TcpClient; -import org.apache.eventmesh.common.protocol.tcp.Command; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SimplePubClientImpl extends TcpClient implements SimplePubClient { - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - private UserAgent userAgent; - - private ReceiveMsgHook callback; - - private ConcurrentHashMap callbackConcurrentHashMap = new ConcurrentHashMap(); - private ScheduledFuture task; - - public SimplePubClientImpl(String accessIp, int port, UserAgent agent) { - super(accessIp, port); - this.userAgent = agent; - } - - public void registerBusiHandler(ReceiveMsgHook handler) throws Exception { - callback = handler; - } - - public void init() throws Exception { - open(new Handler()); - hello(); - logger.info("SimplePubClientImpl|{}|started!", clientNo); - } - - public void reconnect() throws Exception { - super.reconnect(); - hello(); - } - - public void close() { - try { - task.cancel(false); - goodbye(); - super.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public void heartbeat() throws Exception { - task = scheduler.scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - try { - if (!isActive()) { - SimplePubClientImpl.this.reconnect(); - } - Package msg = MessageUtils.heartBeat(); - io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - } catch (Exception ignore) { - } - } - }, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS); - } - - private void goodbye() throws Exception { - Package msg = MessageUtils.goodbye(); - this.io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - } - - private void hello() throws Exception { - Package msg = MessageUtils.hello(userAgent); - this.io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - } - - /** - * Send RR message - * - * @param msg - * @param timeout - * @return - * @throws Exception - */ - public Package rr(Package msg, long timeout) throws Exception { - logger.info("SimplePubClientImpl|{}|rr|send|type={}|msg={}", clientNo, msg.getHeader().getCommand(), msg); - return io(msg, timeout); - } - - /** - * Asynchronous RR - * - * @param msg - * @param callback - * @param timeout - * @throws Exception - */ - @Override - public void asyncRR(Package msg, AsyncRRCallback callback, long timeout) throws Exception { - super.send(msg); - this.callbackConcurrentHashMap.put((String) RequestContext._key(msg), callback); - - } - - /** - * Publish message - * - * @param msg - * @throws Exception - */ - public Package publish(Package msg, long timeout) throws Exception { - logger.info("SimplePubClientImpl|{}|publish|send|type={}|msg={}", clientNo, msg.getHeader().getCommand(), msg); - return io(msg, timeout); - } - - /** - * Send broadcast message - * - * @param msg - * @param timeout - * @throws Exception - */ - public void broadcast(Package msg, long timeout) throws Exception { - logger.info("SimplePubClientImpl|{}|broadcast|send|type={}|msg={}", clientNo, msg.getHeader().getCommand(), msg); - super.send(msg); - } - - @Override - public UserAgent getUserAgent() { - return userAgent; - } - - @ChannelHandler.Sharable - private class Handler extends SimpleChannelInboundHandler { - @Override - protected void channelRead0(ChannelHandlerContext ctx, Package msg) throws Exception { - logger.info("SimplePubClientImpl|{}|receive|type={}|msg={}", clientNo, msg.getHeader(), msg); - - Command cmd = msg.getHeader().getCommand(); - if (cmd == Command.RESPONSE_TO_CLIENT) { - if (callback != null) { - callback.handle(msg, ctx); - } - Package pkg = MessageUtils.responseToClientAck(msg); - send(pkg); - } else if (cmd == Command.SERVER_GOODBYE_REQUEST) { - //TODO - } - - RequestContext context = contexts.get(RequestContext._key(msg)); - if (context != null) { - contexts.remove(context.getKey()); - context.finish(msg); - } - } - } - - @Override - public String toString() { - return "SimplePubClientImpl|clientNo=" + clientNo + "|" + userAgent; - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimpleSubClientImpl.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimpleSubClientImpl.java deleted file mode 100644 index 68d607bde8..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimpleSubClientImpl.java +++ /dev/null @@ -1,185 +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 org.apache.eventmesh.client.tcp.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.SimpleChannelInboundHandler; - -import org.apache.commons.collections4.CollectionUtils; -import org.apache.eventmesh.client.tcp.SimpleSubClient; -import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.client.tcp.common.MessageUtils; -import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; -import org.apache.eventmesh.client.tcp.common.RequestContext; -import org.apache.eventmesh.client.tcp.common.TcpClient; -import org.apache.eventmesh.common.protocol.SubscriptionType; -import org.apache.eventmesh.common.protocol.SubscriptionItem; -import org.apache.eventmesh.common.protocol.SubscriptionMode; -import org.apache.eventmesh.common.protocol.tcp.*; - -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SimpleSubClientImpl extends TcpClient implements SimpleSubClient { - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - private UserAgent userAgent; - - private ReceiveMsgHook callback; - - private List subscriptionItems = new ArrayList(); - - private ScheduledFuture task; - - public SimpleSubClientImpl(String accessIp, int port, UserAgent agent) { - super(accessIp, port); - this.userAgent = agent; - } - - public void registerBusiHandler(ReceiveMsgHook handler) throws Exception { - callback = handler; - } - - public void init() throws Exception { - open(new Handler()); - hello(); - logger.info("SimpleSubClientImpl|{}|started!", clientNo); - } - - public void reconnect() throws Exception { - super.reconnect(); - hello(); - if (!CollectionUtils.isEmpty(subscriptionItems)) { - for (SubscriptionItem item : subscriptionItems) { - Package request = MessageUtils.subscribe(item.getTopic(), item.getMode(), item.getType()); - this.io(request, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - } - } - listen(); - } - - public void close() { - try { - task.cancel(false); - goodbye(); - super.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public void heartbeat() throws Exception { - task = scheduler.scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - try { - if (!isActive()) { - SimpleSubClientImpl.this.reconnect(); - } - Package msg = MessageUtils.heartBeat(); - SimpleSubClientImpl.this.io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - } catch (Exception ignore) { - } - } - }, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS); - } - - private void goodbye() throws Exception { - Package msg = MessageUtils.goodbye(); - this.io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - } - - private void hello() throws Exception { - Package msg = MessageUtils.hello(userAgent); - this.io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - } - - public void listen() throws Exception { - Package request = MessageUtils.listen(); - this.io(request, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - } - - - public void subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) throws Exception { - subscriptionItems.add(new SubscriptionItem(topic, subscriptionMode, subscriptionType)); - Package request = MessageUtils.subscribe(topic, subscriptionMode, subscriptionType); - this.io(request, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - } - - public void unsubscribe() throws Exception { - Package request = MessageUtils.unsubscribe(); - this.io(request, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - } - - public UserAgent getUserAgent() { - return userAgent; - } - - @ChannelHandler.Sharable - private class Handler extends SimpleChannelInboundHandler { - @SuppressWarnings("Duplicates") - @Override - protected void channelRead0(ChannelHandlerContext ctx, Package msg) throws Exception { - Command cmd = msg.getHeader().getCommand(); - logger.info(SimpleSubClientImpl.class.getSimpleName() + "|receive|type={}|msg={}", cmd, msg); - if (cmd == Command.REQUEST_TO_CLIENT) { - if (callback != null) { - callback.handle(msg, ctx); - } - Package pkg = MessageUtils.requestToClientAck(msg); - send(pkg); - } else if (cmd == Command.ASYNC_MESSAGE_TO_CLIENT) { - Package pkg = MessageUtils.asyncMessageAck(msg); - if (callback != null) { - callback.handle(msg, ctx); - } - send(pkg); - } else if (cmd == Command.BROADCAST_MESSAGE_TO_CLIENT) { - Package pkg = MessageUtils.broadcastMessageAck(msg); - if (callback != null) { - callback.handle(msg, ctx); - } - send(pkg); - } else if (cmd == Command.SERVER_GOODBYE_REQUEST) { - //TODO - } else { - logger.error("msg ignored|{}|{}", cmd, msg); - } - RequestContext context = contexts.get(RequestContext._key(msg)); - if (context != null) { - contexts.remove(context.getKey()); - context.finish(msg); - } else { - logger.error("msg ignored,context not found.|{}|{}", cmd, msg); - } - } - } - - @Override - public String toString() { - return "SimpleSubClientImpl|clientNo=" + clientNo + "|" + userAgent; - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/cloudevent/CloudEventTCPClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/cloudevent/CloudEventTCPClient.java new file mode 100644 index 0000000000..abe029825c --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/cloudevent/CloudEventTCPClient.java @@ -0,0 +1,113 @@ +/* + * Licensed 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.eventmesh.client.tcp.impl.cloudevent; + +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPPubClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPSubClient; +import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.SubscriptionMode; +import org.apache.eventmesh.common.protocol.SubscriptionType; +import org.apache.eventmesh.common.protocol.tcp.Package; + +import io.cloudevents.CloudEvent; + +public class CloudEventTCPClient implements EventMeshTCPClient { + + private final CloudEventTCPPubClient cloudEventTCPPubClient; + + private final CloudEventTCPSubClient cloudEventTCPSubClient; + + public CloudEventTCPClient(EventMeshTCPClientConfig eventMeshTcpClientConfig) { + cloudEventTCPPubClient = new CloudEventTCPPubClient(eventMeshTcpClientConfig); + cloudEventTCPSubClient = new CloudEventTCPSubClient(eventMeshTcpClientConfig); + } + + @Override + public void init() throws EventMeshException { + cloudEventTCPPubClient.init(); + cloudEventTCPSubClient.init(); + } + + @Override + public Package rr(CloudEvent cloudEvent, long timeout) throws EventMeshException { + return cloudEventTCPPubClient.rr(cloudEvent, timeout); + } + + @Override + public void asyncRR(CloudEvent cloudEvent, AsyncRRCallback callback, long timeout) throws EventMeshException { + cloudEventTCPPubClient.asyncRR(cloudEvent, callback, timeout); + } + + @Override + public Package publish(CloudEvent cloudEvent, long timeout) throws EventMeshException { + return cloudEventTCPPubClient.publish(cloudEvent, timeout); + } + + @Override + public void broadcast(CloudEvent cloudEvent, long timeout) throws EventMeshException { + cloudEventTCPPubClient.broadcast(cloudEvent, timeout); + } + + @Override + public void listen() throws EventMeshException { + cloudEventTCPSubClient.listen(); + } + + @Override + public void subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) + throws EventMeshException { + cloudEventTCPSubClient.subscribe(topic, subscriptionMode, subscriptionType); + } + + @Override + public void unsubscribe() throws EventMeshException { + cloudEventTCPSubClient.unsubscribe(); + } + + @Override + public void registerPubBusiHandler(ReceiveMsgHook handler) throws EventMeshException { + cloudEventTCPPubClient.registerBusiHandler(handler); + } + + @Override + public void registerSubBusiHandler(ReceiveMsgHook handler) throws EventMeshException { + cloudEventTCPSubClient.registerBusiHandler(handler); + } + + @Override + public void close() throws EventMeshException { + try (final EventMeshTCPPubClient pubClient = cloudEventTCPPubClient; + final EventMeshTCPSubClient subClient = cloudEventTCPSubClient) { + // close client + } + } + + @Override + public EventMeshTCPPubClient getPubClient() { + return cloudEventTCPPubClient; + } + + @Override + public EventMeshTCPSubClient getSubClient() { + return cloudEventTCPSubClient; + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/cloudevent/CloudEventTCPPubClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/cloudevent/CloudEventTCPPubClient.java new file mode 100644 index 0000000000..13262d50b9 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/cloudevent/CloudEventTCPPubClient.java @@ -0,0 +1,172 @@ +/* + * Licensed 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.eventmesh.client.tcp.impl.cloudevent; + +import org.apache.eventmesh.client.tcp.EventMeshTCPPubClient; +import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; +import org.apache.eventmesh.client.tcp.common.MessageUtils; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.common.RequestContext; +import org.apache.eventmesh.client.tcp.common.TcpClient; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.impl.AbstractEventMeshTCPPubHandler; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.Package; + +import java.nio.charset.StandardCharsets; +import java.util.concurrent.ConcurrentHashMap; + +import com.google.common.base.Preconditions; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.format.EventFormat; +import io.cloudevents.core.provider.EventFormatProvider; +import io.cloudevents.jackson.JsonFormat; +import io.netty.channel.ChannelHandlerContext; +import lombok.extern.slf4j.Slf4j; + +/** + * A CloudEvent TCP publish client implementation. + */ +@Slf4j +class CloudEventTCPPubClient extends TcpClient implements EventMeshTCPPubClient { + + private ReceiveMsgHook callback; + + private final ConcurrentHashMap callbackConcurrentHashMap = new ConcurrentHashMap<>(); + + public CloudEventTCPPubClient(EventMeshTCPClientConfig eventMeshTcpClientConfig) { + super(eventMeshTcpClientConfig); + } + + @Override + public void init() throws EventMeshException { + try { + super.open(new CloudEventTCPPubHandler(contexts)); + super.hello(); + super.heartbeat(); + } catch (Exception ex) { + throw new EventMeshException("Initialize EventMeshMessageTCPPubClient error", ex); + } + } + + @Override + public void reconnect() throws EventMeshException { + try { + super.reconnect(); + super.hello(); + } catch (Exception ex) { + throw new EventMeshException("reconnect error", ex); + } + } + + @Override + public Package rr(CloudEvent event, long timeout) throws EventMeshException { + try { + Package msg = MessageUtils.buildPackage(event, Command.REQUEST_TO_SERVER); + log.info("{}|rr|send|type={}|msg={}", clientNo, msg, msg); + return io(msg, timeout); + } catch (Exception ex) { + throw new EventMeshException("rr error"); + } + } + + @Override + public void asyncRR(CloudEvent event, AsyncRRCallback callback, long timeout) throws EventMeshException { + try { + Package msg = MessageUtils.buildPackage(event, Command.REQUEST_TO_SERVER); + super.send(msg); + this.callbackConcurrentHashMap.put((String) RequestContext._key(msg), callback); + } catch (Exception ex) { + // should trigger callback? + throw new EventMeshException("asyncRR error", ex); + } + } + + @Override + public Package publish(CloudEvent cloudEvent, long timeout) throws EventMeshException { + try { + Package msg = MessageUtils.buildPackage(cloudEvent, Command.ASYNC_MESSAGE_TO_SERVER); + log.info("SimplePubClientImpl cloud event|{}|publish|send|type={}|protocol={}|msg={}", + clientNo, msg.getHeader().getCmd(), msg.getHeader().getProperty(Constants.PROTOCOL_TYPE), msg); + return io(msg, timeout); + } catch (Exception ex) { + throw new EventMeshException("publish error", ex); + } + } + + @Override + public void broadcast(CloudEvent cloudEvent, long timeout) throws EventMeshException { + try { + Package msg = MessageUtils.buildPackage(cloudEvent, Command.BROADCAST_MESSAGE_TO_SERVER); + log.info("{}|publish|send|type={}|protocol={}|msg={}", clientNo, msg.getHeader().getCmd(), + msg.getHeader().getProperty(Constants.PROTOCOL_TYPE), msg); + super.send(msg); + } catch (Exception ex) { + throw new EventMeshException("Broadcast message error", ex); + } + } + + @Override + public void registerBusiHandler(ReceiveMsgHook handler) throws EventMeshException { + callback = handler; + } + + @Override + public void close() { + try { + super.close(); + } catch (Exception ex) { + log.error("Close CloudEvent TCP publish client error", ex); + } + } + + private class CloudEventTCPPubHandler extends AbstractEventMeshTCPPubHandler { + + public CloudEventTCPPubHandler(ConcurrentHashMap contexts) { + super(contexts); + } + + @Override + public void callback(CloudEvent cloudEvent, ChannelHandlerContext ctx) { + if (callback != null) { + callback.handle(cloudEvent) + .ifPresent(responseMessage -> ctx.writeAndFlush(MessageUtils.buildPackage(responseMessage, Command.RESPONSE_TO_SERVER))); + } + } + + @Override + public CloudEvent getMessage(Package tcpPackage) { + EventFormat eventFormat = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE); + Preconditions.checkNotNull(eventFormat, + String.format("Cannot find the cloudevent format: %s", JsonFormat.CONTENT_TYPE)); + return eventFormat.deserialize(tcpPackage.getBody().toString().getBytes(StandardCharsets.UTF_8)); + } + + @Override + public void sendResponse(Package tcpPackage) { + try { + send(tcpPackage); + } catch (Exception exception) { + throw new RuntimeException(exception); + } + } + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/cloudevent/CloudEventTCPSubClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/cloudevent/CloudEventTCPSubClient.java new file mode 100644 index 0000000000..068e86daff --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/cloudevent/CloudEventTCPSubClient.java @@ -0,0 +1,174 @@ +/* + * Licensed 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.eventmesh.client.tcp.impl.cloudevent; + +import org.apache.eventmesh.client.tcp.EventMeshTCPSubClient; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.client.tcp.common.MessageUtils; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.common.RequestContext; +import org.apache.eventmesh.client.tcp.common.TcpClient; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.impl.AbstractEventMeshTCPSubHandler; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.SubscriptionItem; +import org.apache.eventmesh.common.protocol.SubscriptionMode; +import org.apache.eventmesh.common.protocol.SubscriptionType; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.Package; + +import org.apache.commons.collections4.CollectionUtils; + +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +import com.google.common.base.Preconditions; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.format.EventFormat; +import io.cloudevents.core.provider.EventFormatProvider; +import io.cloudevents.jackson.JsonFormat; +import io.netty.channel.ChannelHandlerContext; +import lombok.extern.slf4j.Slf4j; + +/** + * CloudEvent TCP subscribe client implementation. + */ +@Slf4j +class CloudEventTCPSubClient extends TcpClient implements EventMeshTCPSubClient { + + private final List subscriptionItems = Collections.synchronizedList(new LinkedList<>()); + private ReceiveMsgHook callback; + + public CloudEventTCPSubClient(EventMeshTCPClientConfig eventMeshTcpClientConfig) { + super(eventMeshTcpClientConfig); + } + + @Override + public void init() throws EventMeshException { + try { + open(new CloudEventTCPSubHandler(contexts)); + hello(); + heartbeat(); + log.info("SimpleSubClientImpl|{}|started!", clientNo); + } catch (Exception ex) { + throw new EventMeshException("Initialize EventMeshMessageTcpSubClient error", ex); + } + } + + @Override + public void reconnect() throws EventMeshException { + try { + super.reconnect(); + hello(); + if (!CollectionUtils.isEmpty(subscriptionItems)) { + for (SubscriptionItem item : subscriptionItems) { + Package request = MessageUtils.subscribe(item.getTopic(), item.getMode(), item.getType()); + this.io(request, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + } + } + listen(); + } catch (Exception ex) { + // + } + } + + @Override + public void subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) + throws EventMeshException { + try { + subscriptionItems.add(new SubscriptionItem(topic, subscriptionMode, subscriptionType)); + Package request = MessageUtils.subscribe(topic, subscriptionMode, subscriptionType); + io(request, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + } catch (Exception ex) { + throw new EventMeshException("Subscribe error", ex); + } + } + + @Override + public void unsubscribe() throws EventMeshException { + try { + Package request = MessageUtils.unsubscribe(); + io(request, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + } catch (Exception ex) { + throw new EventMeshException("Unsubscribe error", ex); + } + } + + @Override + public void listen() throws EventMeshException { + try { + Package request = MessageUtils.listen(); + io(request, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + } catch (Exception ex) { + throw new EventMeshException("Listen error", ex); + } + } + + @Override + public void registerBusiHandler(ReceiveMsgHook handler) throws EventMeshException { + this.callback = handler; + } + + @Override + public void close() { + try { + goodbye(); + super.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + private class CloudEventTCPSubHandler extends AbstractEventMeshTCPSubHandler { + + public CloudEventTCPSubHandler( + ConcurrentHashMap contexts) { + super(contexts); + } + + @Override + public CloudEvent getProtocolMessage(Package tcpPackage) { + EventFormat eventFormat = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE); + Preconditions.checkNotNull(eventFormat, + String.format("Cannot find the cloudevent format: %s", JsonFormat.CONTENT_TYPE)); + return eventFormat.deserialize(tcpPackage.getBody().toString().getBytes(StandardCharsets.UTF_8)); + } + + @Override + public void callback(CloudEvent cloudEvent, ChannelHandlerContext ctx) { + if (callback != null) { + callback.handle(cloudEvent).ifPresent( + responseMessage -> ctx.writeAndFlush(MessageUtils.buildPackage(responseMessage, Command.RESPONSE_TO_SERVER)) + ); + } + } + + @Override + public void response(Package tcpPackage) { + try { + send(tcpPackage); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/eventmeshmessage/EventMeshMessageTCPClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/eventmeshmessage/EventMeshMessageTCPClient.java new file mode 100644 index 0000000000..6faf050c06 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/eventmeshmessage/EventMeshMessageTCPClient.java @@ -0,0 +1,112 @@ +/* + * Licensed 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.eventmesh.client.tcp.impl.eventmeshmessage; + +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPPubClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPSubClient; +import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.SubscriptionMode; +import org.apache.eventmesh.common.protocol.SubscriptionType; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; +import org.apache.eventmesh.common.protocol.tcp.Package; + +public class EventMeshMessageTCPClient implements EventMeshTCPClient { + + private final EventMeshTCPPubClient eventMeshMessageTCPPubClient; + private final EventMeshTCPSubClient eventMeshMessageTCPSubClient; + + public EventMeshMessageTCPClient(EventMeshTCPClientConfig eventMeshTcpClientConfig) { + eventMeshMessageTCPPubClient = new EventMeshMessageTCPPubClient(eventMeshTcpClientConfig); + eventMeshMessageTCPSubClient = new EventMeshMessageTCPSubClient(eventMeshTcpClientConfig); + } + + @Override + public void init() throws EventMeshException { + eventMeshMessageTCPPubClient.init(); + eventMeshMessageTCPSubClient.init(); + } + + @Override + public Package rr(EventMeshMessage eventMeshMessage, long timeout) throws EventMeshException { + return eventMeshMessageTCPPubClient.rr(eventMeshMessage, timeout); + } + + @Override + public void asyncRR(EventMeshMessage eventMeshMessage, AsyncRRCallback callback, long timeout) + throws EventMeshException { + eventMeshMessageTCPPubClient.asyncRR(eventMeshMessage, callback, timeout); + } + + @Override + public Package publish(EventMeshMessage eventMeshMessage, long timeout) throws EventMeshException { + return eventMeshMessageTCPPubClient.publish(eventMeshMessage, timeout); + } + + @Override + public void broadcast(EventMeshMessage eventMeshMessage, long timeout) throws EventMeshException { + eventMeshMessageTCPPubClient.broadcast(eventMeshMessage, timeout); + } + + @Override + public void listen() throws EventMeshException { + eventMeshMessageTCPSubClient.listen(); + } + + @Override + public void subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) + throws EventMeshException { + eventMeshMessageTCPSubClient.subscribe(topic, subscriptionMode, subscriptionType); + } + + @Override + public void unsubscribe() throws EventMeshException { + eventMeshMessageTCPSubClient.unsubscribe(); + } + + @Override + public void registerPubBusiHandler(ReceiveMsgHook handler) throws EventMeshException { + eventMeshMessageTCPPubClient.registerBusiHandler(handler); + } + + @Override + public void registerSubBusiHandler(ReceiveMsgHook handler) throws EventMeshException { + eventMeshMessageTCPSubClient.registerBusiHandler(handler); + } + + @Override + public void close() throws EventMeshException { + try (final EventMeshTCPPubClient eventMeshTCPPubClient = eventMeshMessageTCPPubClient; + final EventMeshTCPSubClient eventMeshTCPSubClient = eventMeshMessageTCPSubClient) { + // close client + } + } + + @Override + public EventMeshTCPPubClient getPubClient() { + return eventMeshMessageTCPPubClient; + } + + @Override + public EventMeshTCPSubClient getSubClient() { + return eventMeshMessageTCPSubClient; + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/eventmeshmessage/EventMeshMessageTCPPubClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/eventmeshmessage/EventMeshMessageTCPPubClient.java new file mode 100644 index 0000000000..ae189f252c --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/eventmeshmessage/EventMeshMessageTCPPubClient.java @@ -0,0 +1,171 @@ +/* + * Licensed 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.eventmesh.client.tcp.impl.eventmeshmessage; + +import org.apache.eventmesh.client.tcp.EventMeshTCPPubClient; +import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; +import org.apache.eventmesh.client.tcp.common.MessageUtils; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.common.RequestContext; +import org.apache.eventmesh.client.tcp.common.TcpClient; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.impl.AbstractEventMeshTCPPubHandler; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.utils.JsonUtils; + +import java.util.concurrent.ConcurrentHashMap; + +import io.netty.channel.ChannelHandlerContext; +import lombok.extern.slf4j.Slf4j; + +/** + * EventMeshMessage TCP publish client implementation. + */ +@Slf4j +class EventMeshMessageTCPPubClient extends TcpClient implements EventMeshTCPPubClient { + + private ReceiveMsgHook callback; + + private final ConcurrentHashMap callbackConcurrentHashMap = new ConcurrentHashMap<>(); + + public EventMeshMessageTCPPubClient(EventMeshTCPClientConfig eventMeshTcpClientConfig) { + super(eventMeshTcpClientConfig); + } + + @Override + public void init() throws EventMeshException { + try { + open(new EventMeshTCPPubHandler(contexts)); + hello(); + heartbeat(); + } catch (Exception ex) { + throw new EventMeshException("Initialize EventMeshMessageTCPPubClient error", ex); + } + + } + + @Override + public void reconnect() throws EventMeshException { + try { + super.reconnect(); + hello(); + } catch (Exception ex) { + throw new EventMeshException("reconnect error", ex); + } + } + + // todo: Maybe use org.apache.eventmesh.common.EvetMesh here is better + @Override + public Package rr(EventMeshMessage eventMeshMessage, long timeout) throws EventMeshException { + try { + Package msg = MessageUtils.buildPackage(eventMeshMessage, Command.REQUEST_TO_SERVER); + log.info("{}|rr|send|type={}|msg={}", clientNo, msg, msg); + return io(msg, timeout); + } catch (Exception ex) { + throw new EventMeshException("rr error"); + } + } + + @Override + public void asyncRR(EventMeshMessage eventMeshMessage, AsyncRRCallback callback, long timeout) + throws EventMeshException { + try { + Package msg = MessageUtils.buildPackage(eventMeshMessage, Command.REQUEST_TO_SERVER); + super.send(msg); + this.callbackConcurrentHashMap.put((String) RequestContext._key(msg), callback); + } catch (Exception ex) { + // should trigger callback? + throw new EventMeshException("asyncRR error", ex); + } + } + + @Override + public Package publish(EventMeshMessage eventMeshMessage, long timeout) throws EventMeshException { + try { + Package msg = MessageUtils.buildPackage(eventMeshMessage, Command.ASYNC_MESSAGE_TO_SERVER); + log.info("SimplePubClientImpl em message|{}|publish|send|type={}|protocol={}|msg={}", + clientNo, msg.getHeader().getCmd(), + msg.getHeader().getProperty(Constants.PROTOCOL_TYPE), msg); + return io(msg, timeout); + } catch (Exception ex) { + throw new EventMeshException("publish error", ex); + } + } + + @Override + public void broadcast(EventMeshMessage eventMeshMessage, long timeout) throws EventMeshException { + try { + // todo: transform EventMeshMessage to Package + Package msg = MessageUtils.buildPackage(eventMeshMessage, Command.BROADCAST_MESSAGE_TO_SERVER); + log.info("{}|publish|send|type={}|protocol={}|msg={}", clientNo, msg.getHeader().getCmd(), + msg.getHeader().getProperty(Constants.PROTOCOL_TYPE), msg); + super.send(msg); + } catch (Exception ex) { + throw new EventMeshException("Broadcast message error", ex); + } + } + + @Override + public void registerBusiHandler(ReceiveMsgHook receiveMsgHook) throws EventMeshException { + this.callback = receiveMsgHook; + } + + @Override + public void close() { + try { + super.close(); + } catch (Exception e) { + log.error("Close EventMeshMessage TCP publish client error", e); + } + } + + private class EventMeshTCPPubHandler extends AbstractEventMeshTCPPubHandler { + + public EventMeshTCPPubHandler(ConcurrentHashMap contexts) { + super(contexts); + } + + @Override + public void callback(EventMeshMessage eventMeshMessage, ChannelHandlerContext ctx) { + if (callback != null) { + callback.handle(eventMeshMessage).ifPresent( + responseMessage -> ctx.writeAndFlush(MessageUtils.buildPackage(responseMessage, Command.RESPONSE_TO_SERVER)) + ); + } + } + + @Override + public EventMeshMessage getMessage(Package tcpPackage) { + return JsonUtils.deserialize(tcpPackage.getBody().toString(), EventMeshMessage.class); + } + + @Override + public void sendResponse(Package tcpPackage) { + try { + send(tcpPackage); + } catch (Exception exception) { + throw new RuntimeException(exception); + } + } + } + +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/eventmeshmessage/EventMeshMessageTCPSubClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/eventmeshmessage/EventMeshMessageTCPSubClient.java new file mode 100644 index 0000000000..c03894d21f --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/eventmeshmessage/EventMeshMessageTCPSubClient.java @@ -0,0 +1,160 @@ +/* + * Licensed 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.eventmesh.client.tcp.impl.eventmeshmessage; + +import org.apache.eventmesh.client.tcp.EventMeshTCPSubClient; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.client.tcp.common.MessageUtils; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.common.RequestContext; +import org.apache.eventmesh.client.tcp.common.TcpClient; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.impl.AbstractEventMeshTCPSubHandler; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.SubscriptionItem; +import org.apache.eventmesh.common.protocol.SubscriptionMode; +import org.apache.eventmesh.common.protocol.SubscriptionType; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.utils.JsonUtils; + +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +import io.netty.channel.ChannelHandlerContext; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class EventMeshMessageTCPSubClient extends TcpClient implements EventMeshTCPSubClient { + + private final List subscriptionItems = Collections.synchronizedList(new LinkedList<>()); + private ReceiveMsgHook callback; + + public EventMeshMessageTCPSubClient(EventMeshTCPClientConfig eventMeshTcpClientConfig) { + super(eventMeshTcpClientConfig); + } + + @Override + public void init() throws EventMeshException { + try { + open(new EventMeshMessageTCPSubHandler(contexts)); + hello(); + heartbeat(); + log.info("SimpleSubClientImpl|{}|started!", clientNo); + } catch (Exception ex) { + throw new EventMeshException("Initialize EventMeshMessageTcpSubClient error", ex); + } + } + + @Override + public void reconnect() throws EventMeshException { + try { + super.reconnect(); + hello(); + if (!CollectionUtils.isEmpty(subscriptionItems)) { + for (SubscriptionItem item : subscriptionItems) { + Package request = MessageUtils.subscribe(item.getTopic(), item.getMode(), item.getType()); + this.io(request, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + } + } + listen(); + } catch (Exception ex) { + // + } + } + + @Override + public void subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) + throws EventMeshException { + try { + subscriptionItems.add(new SubscriptionItem(topic, subscriptionMode, subscriptionType)); + Package request = MessageUtils.subscribe(topic, subscriptionMode, subscriptionType); + io(request, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + } catch (Exception ex) { + throw new EventMeshException("Subscribe error", ex); + } + } + + @Override + public void unsubscribe() throws EventMeshException { + try { + Package request = MessageUtils.unsubscribe(); + io(request, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + } catch (Exception ex) { + throw new EventMeshException("Unsubscribe error", ex); + } + } + + public void listen() throws EventMeshException { + try { + Package request = MessageUtils.listen(); + io(request, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); + } catch (Exception ex) { + throw new EventMeshException("Listen error", ex); + } + } + + + @Override + public void registerBusiHandler(ReceiveMsgHook receiveMsgHook) throws EventMeshException { + this.callback = receiveMsgHook; + } + + @Override + public void close() { + try { + super.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + private class EventMeshMessageTCPSubHandler extends AbstractEventMeshTCPSubHandler { + public EventMeshMessageTCPSubHandler(ConcurrentHashMap contexts) { + super(contexts); + } + + @Override + public EventMeshMessage getProtocolMessage(Package tcpPackage) { + return JsonUtils.deserialize(tcpPackage.getBody().toString(), EventMeshMessage.class); + } + + @Override + public void callback(EventMeshMessage eventMeshMessage, ChannelHandlerContext ctx) { + if (callback != null) { + callback.handle(eventMeshMessage).ifPresent( + responseMessage -> ctx.writeAndFlush(MessageUtils.buildPackage(responseMessage, Command.RESPONSE_TO_SERVER)) + ); + } + } + + @Override + public void response(Package tcpPackage) { + try { + send(tcpPackage); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/openmessage/OpenMessageTCPClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/openmessage/OpenMessageTCPClient.java new file mode 100644 index 0000000000..25a929e5c5 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/openmessage/OpenMessageTCPClient.java @@ -0,0 +1,114 @@ +/* + * Licensed 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.eventmesh.client.tcp.impl.openmessage; + +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPPubClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPSubClient; +import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.SubscriptionMode; +import org.apache.eventmesh.common.protocol.SubscriptionType; +import org.apache.eventmesh.common.protocol.tcp.Package; + +import io.openmessaging.api.Message; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class OpenMessageTCPClient implements EventMeshTCPClient { + + private final EventMeshTCPPubClient eventMeshTCPPubClient; + private final EventMeshTCPSubClient eventMeshTCPSubClient; + + public OpenMessageTCPClient(EventMeshTCPClientConfig eventMeshTCPClientConfig) { + eventMeshTCPPubClient = new OpenMessageTCPPubClient(eventMeshTCPClientConfig); + eventMeshTCPSubClient = new OpenMessageTCPSubClient(eventMeshTCPClientConfig); + } + + @Override + public void init() throws EventMeshException { + eventMeshTCPPubClient.init(); + eventMeshTCPSubClient.init(); + } + + @Override + public Package rr(Message openMessage, long timeout) throws EventMeshException { + return eventMeshTCPPubClient.rr(openMessage, timeout); + } + + @Override + public void asyncRR(Message openMessage, AsyncRRCallback callback, long timeout) throws EventMeshException { + eventMeshTCPPubClient.asyncRR(openMessage, callback, timeout); + } + + @Override + public Package publish(Message openMessage, long timeout) throws EventMeshException { + return eventMeshTCPPubClient.publish(openMessage, timeout); + } + + @Override + public void broadcast(Message openMessage, long timeout) throws EventMeshException { + eventMeshTCPPubClient.broadcast(openMessage, timeout); + } + + @Override + public void listen() throws EventMeshException { + eventMeshTCPSubClient.listen(); + } + + @Override + public void subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) + throws EventMeshException { + eventMeshTCPSubClient.subscribe(topic, subscriptionMode, subscriptionType); + } + + @Override + public void unsubscribe() throws EventMeshException { + eventMeshTCPSubClient.unsubscribe(); + } + + @Override + public void registerPubBusiHandler(ReceiveMsgHook handler) throws EventMeshException { + eventMeshTCPPubClient.registerBusiHandler(handler); + } + + @Override + public void registerSubBusiHandler(ReceiveMsgHook handler) throws EventMeshException { + eventMeshTCPSubClient.registerBusiHandler(handler); + } + + @Override + public void close() throws EventMeshException { + try (final EventMeshTCPPubClient pubClient = eventMeshTCPPubClient; + final EventMeshTCPSubClient subClient = eventMeshTCPSubClient) { + log.info("Close OpenMessageTCPClient"); + } + } + + @Override + public EventMeshTCPPubClient getPubClient() { + return eventMeshTCPPubClient; + } + + @Override + public EventMeshTCPSubClient getSubClient() { + return eventMeshTCPSubClient; + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/openmessage/OpenMessageTCPPubClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/openmessage/OpenMessageTCPPubClient.java new file mode 100644 index 0000000000..3eebdd206d --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/openmessage/OpenMessageTCPPubClient.java @@ -0,0 +1,78 @@ +/* + * Licensed 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.eventmesh.client.tcp.impl.openmessage; + +import org.apache.eventmesh.client.tcp.EventMeshTCPPubClient; +import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.tcp.Package; + +import io.openmessaging.api.Message; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class OpenMessageTCPPubClient implements EventMeshTCPPubClient { + + private final EventMeshTCPClientConfig eventMeshTCPClientConfig; + + public OpenMessageTCPPubClient(final EventMeshTCPClientConfig eventMeshTCPClientConfig) { + this.eventMeshTCPClientConfig = eventMeshTCPClientConfig; + } + + @Override + public void init() throws EventMeshException { + + } + + @Override + public void reconnect() throws EventMeshException { + + } + + @Override + public Package rr(Message msg, long timeout) throws EventMeshException { + return null; + } + + @Override + public void asyncRR(Message msg, AsyncRRCallback callback, long timeout) throws EventMeshException { + + } + + @Override + public Package publish(Message cloudEvent, long timeout) throws EventMeshException { + return null; + } + + @Override + public void broadcast(Message cloudEvent, long timeout) throws EventMeshException { + + } + + @Override + public void registerBusiHandler(ReceiveMsgHook handler) throws EventMeshException { + + } + + @Override + public void close() throws EventMeshException { + + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/openmessage/OpenMessageTCPSubClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/openmessage/OpenMessageTCPSubClient.java new file mode 100644 index 0000000000..34c3ad0380 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/openmessage/OpenMessageTCPSubClient.java @@ -0,0 +1,74 @@ +/* + * Licensed 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.eventmesh.client.tcp.impl.openmessage; + +import org.apache.eventmesh.client.tcp.EventMeshTCPSubClient; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.common.exception.EventMeshException; +import org.apache.eventmesh.common.protocol.SubscriptionMode; +import org.apache.eventmesh.common.protocol.SubscriptionType; + +import io.openmessaging.api.Message; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class OpenMessageTCPSubClient implements EventMeshTCPSubClient { + + private final EventMeshTCPClientConfig eventMeshTCPClientConfig; + + public OpenMessageTCPSubClient(EventMeshTCPClientConfig eventMeshTCPClientConfig) { + this.eventMeshTCPClientConfig = eventMeshTCPClientConfig; + } + + @Override + public void init() throws EventMeshException { + + } + + @Override + public void reconnect() throws EventMeshException { + + } + + @Override + public void subscribe(String topic, SubscriptionMode subscriptionMode, SubscriptionType subscriptionType) + throws EventMeshException { + + } + + @Override + public void unsubscribe() throws EventMeshException { + + } + + @Override + public void listen() throws EventMeshException { + + } + + @Override + public void registerBusiHandler(ReceiveMsgHook handler) throws EventMeshException { + + } + + @Override + public void close() throws EventMeshException { + + } +} diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncPublishInstance.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncPublishInstance.java index c3447aa438..1095de392b 100644 --- a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncPublishInstance.java +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncPublishInstance.java @@ -17,69 +17,49 @@ package org.apache.eventmesh.client.http.demo; -import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.client.http.conf.LiteClientConfig; -import org.apache.eventmesh.client.http.producer.LiteProducer; +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.producer.EventMeshHttpProducer; import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.LiteMessage; -import org.apache.eventmesh.common.RandomStringUtil; -import org.apache.eventmesh.common.ThreadUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.eventmesh.common.EventMeshMessage; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; -public class AsyncPublishInstance { +import lombok.extern.slf4j.Slf4j; - public static Logger logger = LoggerFactory.getLogger(AsyncPublishInstance.class); +@Slf4j +public class AsyncPublishInstance { public static void main(String[] args) throws Exception { - LiteProducer liteProducer = null; - try { -// String eventMeshIPPort = args[0]; - String eventMeshIPPort = ""; -// final String topic = args[1]; - final String topic = "TEST-TOPIC-HTTP-ASYNC"; - if (StringUtils.isBlank(eventMeshIPPort)) { - // if has multi value, can config as: 127.0.0.1:10105;127.0.0.2:10105 - eventMeshIPPort = "127.0.0.1:10105"; - } + String eventMeshIPPort = "127.0.0.1:10105"; + final String topic = "TEST-TOPIC-HTTP-ASYNC"; - LiteClientConfig eventMeshClientConfig = new LiteClientConfig(); - eventMeshClientConfig.setLiteEventMeshAddr(eventMeshIPPort) - .setProducerGroup("EventMeshTest-producerGroup") - .setEnv("env") - .setIdc("idc") - .setIp(IPUtil.getLocalAddress()) - .setSys("1234") - .setPid(String.valueOf(ThreadUtil.getPID())); + EventMeshHttpClientConfig eventMeshClientConfig = EventMeshHttpClientConfig.builder() + .liteEventMeshAddr(eventMeshIPPort) + .producerGroup("EventMeshTest-producerGroup") + .env("env") + .idc("idc") + .ip(IPUtils.getLocalAddress()) + .sys("1234") + .pid(String.valueOf(ThreadUtils.getPID())).build(); - liteProducer = new LiteProducer(eventMeshClientConfig); - liteProducer.start(); - for (int i = 0; i < 1; i++) { - LiteMessage liteMessage = new LiteMessage(); - liteMessage.setBizSeqNo(RandomStringUtil.generateNum(30)) -// .setContent("contentStr with special protocal") - .setContent("testPublishMessage") - .setTopic(topic) - .setUniqueId(RandomStringUtil.generateNum(30)) - .addProp(Constants.EVENTMESH_MESSAGE_CONST_TTL, String.valueOf(4 * 1000)); + EventMeshHttpProducer eventMeshHttpProducer = new EventMeshHttpProducer(eventMeshClientConfig); + for (int i = 0; i < 1; i++) { + EventMeshMessage eventMeshMessage = EventMeshMessage.builder() + .bizSeqNo(RandomStringUtils.generateNum(30)) + .content("testPublishMessage") + .topic(topic) + .uniqueId(RandomStringUtils.generateNum(30)) + .build() + .addProp(Constants.EVENTMESH_MESSAGE_CONST_TTL, String.valueOf(4 * 1000)); - boolean flag = liteProducer.publish(liteMessage); - Thread.sleep(1000); - logger.info("publish result , {}", flag); - } - } catch (Exception e) { - logger.warn("publish msg failed", e); + eventMeshHttpProducer.publish(eventMeshMessage); + Thread.sleep(1000); } - - try { - Thread.sleep(30000); - if (liteProducer != null) { - liteProducer.shutdown(); - } - } catch (Exception e1) { - logger.warn("producer shutdown exception", e1); + Thread.sleep(30000); + try (EventMeshHttpProducer ignore = eventMeshHttpProducer) { + // ignore } } } diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncSyncRequestInstance.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncSyncRequestInstance.java index d9888ebfae..28fe47ccae 100644 --- a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncSyncRequestInstance.java +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncSyncRequestInstance.java @@ -18,14 +18,16 @@ package org.apache.eventmesh.client.http.demo; -import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.client.http.conf.LiteClientConfig; -import org.apache.eventmesh.client.http.producer.LiteProducer; +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.producer.EventMeshHttpProducer; import org.apache.eventmesh.client.http.producer.RRCallback; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.LiteMessage; -import org.apache.eventmesh.common.RandomStringUtil; -import org.apache.eventmesh.common.ThreadUtil; +import org.apache.eventmesh.common.EventMeshMessage; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; + +import org.apache.commons.lang3.StringUtils; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +37,7 @@ public class AsyncSyncRequestInstance { public static void main(String[] args) throws Exception { - LiteProducer liteProducer = null; + EventMeshHttpProducer eventMeshHttpProducer = null; try { // String eventMeshIPPort = args[0]; String eventMeshIPPort = ""; @@ -46,28 +48,29 @@ public static void main(String[] args) throws Exception { eventMeshIPPort = "127.0.0.1:10105"; } - LiteClientConfig eventMeshClientConfig = new LiteClientConfig(); - eventMeshClientConfig.setLiteEventMeshAddr(eventMeshIPPort) - .setProducerGroup("EventMeshTest-producerGroup") - .setEnv("env") - .setIdc("idc") - .setIp(IPUtil.getLocalAddress()) - .setSys("1234") - .setPid(String.valueOf(ThreadUtil.getPID())); + EventMeshHttpClientConfig eventMeshClientConfig = EventMeshHttpClientConfig.builder() + .liteEventMeshAddr(eventMeshIPPort) + .producerGroup("EventMeshTest-producerGroup") + .env("env") + .idc("idc") + .ip(IPUtils.getLocalAddress()) + .sys("1234") + .pid(String.valueOf(ThreadUtils.getPID())).build(); - liteProducer = new LiteProducer(eventMeshClientConfig); + eventMeshHttpProducer = new EventMeshHttpProducer(eventMeshClientConfig); final long startTime = System.currentTimeMillis(); - final LiteMessage liteMessage = new LiteMessage(); - liteMessage.setBizSeqNo(RandomStringUtil.generateNum(30)) - .setContent("testAsyncMessage") - .setTopic(topic) - .setUniqueId(RandomStringUtil.generateNum(30)); + final EventMeshMessage eventMeshMessage = EventMeshMessage.builder() + .bizSeqNo(RandomStringUtils.generateNum(30)) + .content("testAsyncMessage") + .topic(topic) + .uniqueId(RandomStringUtils.generateNum(30)).build(); - liteProducer.request(liteMessage, new RRCallback() { + eventMeshHttpProducer.request(eventMeshMessage, new RRCallback() { @Override - public void onSuccess(LiteMessage o) { - logger.debug("sendmsg : {}, return : {}, cost:{}ms", liteMessage.getContent(), o.getContent(), System.currentTimeMillis() - startTime); + public void onSuccess(EventMeshMessage o) { + logger.debug("sendmsg : {}, return : {}, cost:{}ms", eventMeshMessage.getContent(), o.getContent(), + System.currentTimeMillis() - startTime); } @Override @@ -81,11 +84,9 @@ public void onException(Throwable e) { logger.warn("async send msg failed", e); } - try { - Thread.sleep(30000); - if (liteProducer != null) { - liteProducer.shutdown(); - } + Thread.sleep(30000); + try (final EventMeshHttpProducer ignore = eventMeshHttpProducer) { + // close producer } catch (Exception e1) { logger.warn("producer shutdown exception", e1); } diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/SyncRequestInstance.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/SyncRequestInstance.java index 2b16cde5af..30e7142ebf 100644 --- a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/SyncRequestInstance.java +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/SyncRequestInstance.java @@ -17,13 +17,15 @@ package org.apache.eventmesh.client.http.demo; +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.client.http.producer.EventMeshHttpProducer; +import org.apache.eventmesh.common.EventMeshMessage; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; + import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.client.http.conf.LiteClientConfig; -import org.apache.eventmesh.client.http.producer.LiteProducer; -import org.apache.eventmesh.common.IPUtil; -import org.apache.eventmesh.common.LiteMessage; -import org.apache.eventmesh.common.RandomStringUtil; -import org.apache.eventmesh.common.ThreadUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +35,7 @@ public class SyncRequestInstance { public static void main(String[] args) throws Exception { - LiteProducer liteProducer = null; + EventMeshHttpProducer eventMeshHttpProducer = null; try { String eventMeshIPPort = args[0]; @@ -44,38 +46,36 @@ public static void main(String[] args) throws Exception { eventMeshIPPort = "127.0.0.1:10105"; } - LiteClientConfig eventMeshClientConfig = new LiteClientConfig(); - eventMeshClientConfig.setLiteEventMeshAddr(eventMeshIPPort) - .setProducerGroup("EventMeshTest-producerGroup") - .setEnv("env") - .setIdc("idc") - .setIp(IPUtil.getLocalAddress()) - .setSys("1234") - .setPid(String.valueOf(ThreadUtil.getPID())); + EventMeshHttpClientConfig eventMeshClientConfig = EventMeshHttpClientConfig.builder() + .liteEventMeshAddr(eventMeshIPPort) + .producerGroup("EventMeshTest-producerGroup") + .env("env") + .idc("idc") + .ip(IPUtils.getLocalAddress()) + .sys("1234") + .pid(String.valueOf(ThreadUtils.getPID())).build(); - liteProducer = new LiteProducer(eventMeshClientConfig); - liteProducer.start(); + eventMeshHttpProducer = new EventMeshHttpProducer(eventMeshClientConfig); long startTime = System.currentTimeMillis(); - LiteMessage liteMessage = new LiteMessage(); - liteMessage.setBizSeqNo(RandomStringUtil.generateNum(30)) - .setContent("contentStr with special protocal") - .setTopic(topic) - .setUniqueId(RandomStringUtil.generateNum(30)); + EventMeshMessage eventMeshMessage = EventMeshMessage.builder() + .bizSeqNo(RandomStringUtils.generateNum(30)) + .content("contentStr with special protocal") + .topic(topic) + .uniqueId(RandomStringUtils.generateNum(30)).build(); - LiteMessage rsp = liteProducer.request(liteMessage, 10000); + EventMeshMessage rsp = eventMeshHttpProducer.request(eventMeshMessage, 10000); if (logger.isDebugEnabled()) { - logger.debug("sendmsg : {}, return : {}, cost:{}ms", liteMessage.getContent(), rsp.getContent(), System.currentTimeMillis() - startTime); + logger.debug("sendmsg : {}, return : {}, cost:{}ms", eventMeshMessage.getContent(), rsp.getContent(), + System.currentTimeMillis() - startTime); } } catch (Exception e) { logger.warn("send msg failed", e); } - try { - Thread.sleep(30000); - if (liteProducer != null) { - liteProducer.shutdown(); - } + Thread.sleep(30000); + try (final EventMeshHttpProducer closed = eventMeshHttpProducer){ + // close producer } catch (Exception e1) { logger.warn("producer shutdown exception", e1); } diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/util/HttpLoadBalanceUtilsTest.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/util/HttpLoadBalanceUtilsTest.java index 7355c4f156..aabafb1d69 100644 --- a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/util/HttpLoadBalanceUtilsTest.java +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/util/HttpLoadBalanceUtilsTest.java @@ -17,8 +17,8 @@ package org.apache.eventmesh.client.http.util; -import org.apache.eventmesh.client.http.conf.LiteClientConfig; -import org.apache.eventmesh.common.EventMeshException; +import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; +import org.apache.eventmesh.common.exception.EventMeshException; import org.apache.eventmesh.common.loadbalance.LoadBalanceSelector; import org.apache.eventmesh.common.loadbalance.LoadBalanceType; import org.junit.Assert; @@ -28,30 +28,31 @@ public class HttpLoadBalanceUtilsTest { @Test public void testCreateRandomSelector() throws EventMeshException { - LiteClientConfig liteClientConfig = new LiteClientConfig() - .setLiteEventMeshAddr("127.0.0.1:1001;127.0.0.2:1002"); + EventMeshHttpClientConfig eventMeshHttpClientConfig = EventMeshHttpClientConfig.builder() + .liteEventMeshAddr("127.0.0.1:1001;127.0.0.2:1002") + .build(); LoadBalanceSelector randomSelector = HttpLoadBalanceUtils - .createEventMeshServerLoadBalanceSelector(liteClientConfig); + .createEventMeshServerLoadBalanceSelector(eventMeshHttpClientConfig); Assert.assertEquals(LoadBalanceType.RANDOM, randomSelector.getType()); } @Test public void testCreateWeightRoundRobinSelector() throws EventMeshException { - LiteClientConfig liteClientConfig = new LiteClientConfig() - .setLiteEventMeshAddr("127.0.0.1:1001:1;127.0.0.2:1001:2") - .setLoadBalanceType(LoadBalanceType.WEIGHT_ROUND_ROBIN); + EventMeshHttpClientConfig eventMeshHttpClientConfig = EventMeshHttpClientConfig.builder() + .liteEventMeshAddr("127.0.0.1:1001:1;127.0.0.2:1001:2") + .loadBalanceType(LoadBalanceType.WEIGHT_ROUND_ROBIN).build(); LoadBalanceSelector weightRoundRobinSelector = HttpLoadBalanceUtils - .createEventMeshServerLoadBalanceSelector(liteClientConfig); + .createEventMeshServerLoadBalanceSelector(eventMeshHttpClientConfig); Assert.assertEquals(LoadBalanceType.WEIGHT_ROUND_ROBIN, weightRoundRobinSelector.getType()); } @Test public void testCreateWeightRandomSelector() throws EventMeshException { - LiteClientConfig liteClientConfig = new LiteClientConfig() - .setLiteEventMeshAddr("127.0.0.1:1001:1;127.0.0.2:1001:2") - .setLoadBalanceType(LoadBalanceType.WEIGHT_RANDOM); + EventMeshHttpClientConfig eventMeshHttpClientConfig = EventMeshHttpClientConfig.builder() + .liteEventMeshAddr("127.0.0.1:1001:1;127.0.0.2:1001:2") + .loadBalanceType(LoadBalanceType.WEIGHT_RANDOM).build(); LoadBalanceSelector weightRoundRobinSelector = HttpLoadBalanceUtils - .createEventMeshServerLoadBalanceSelector(liteClientConfig); + .createEventMeshServerLoadBalanceSelector(eventMeshHttpClientConfig); Assert.assertEquals(LoadBalanceType.WEIGHT_RANDOM, weightRoundRobinSelector.getType()); } } \ No newline at end of file diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/common/EventMeshTestUtils.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/common/EventMeshTestUtils.java index 78e1016756..f90a2d25ef 100644 --- a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/common/EventMeshTestUtils.java +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/common/EventMeshTestUtils.java @@ -20,53 +20,48 @@ import static org.apache.eventmesh.client.tcp.common.EventMeshTestCaseTopicSet.TOPIC_PRX_SyncSubscribeTest; import static org.apache.eventmesh.client.tcp.common.EventMeshTestCaseTopicSet.TOPIC_PRX_WQ2ClientBroadCast; import static org.apache.eventmesh.client.tcp.common.EventMeshTestCaseTopicSet.TOPIC_PRX_WQ2ClientUniCast; - -import java.util.concurrent.ThreadLocalRandom; +import static org.apache.eventmesh.common.protocol.tcp.Command.RESPONSE_TO_SERVER; import org.apache.eventmesh.common.protocol.tcp.Command; import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; import org.apache.eventmesh.common.protocol.tcp.Header; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; -import static org.apache.eventmesh.common.protocol.tcp.Command.RESPONSE_TO_SERVER; - - - +import java.util.concurrent.ThreadLocalRandom; public class EventMeshTestUtils { private static final int seqLength = 10; public static UserAgent generateClient1() { - UserAgent user = new UserAgent(); - user.setHost("127.0.0.1"); - user.setPassword(generateRandomString(8)); - user.setUsername("PU4283"); - user.setConsumerGroup("EventmeshTest-ConsumerGroup"); - user.setProducerGroup("EventmeshTest-ProducerGroup"); - user.setPath("/data/app/umg_proxy"); - user.setPort(8362); - user.setSubsystem("5023"); - user.setPid(32893); - user.setVersion("2.0.11"); - user.setIdc("FT"); - return user; + return UserAgent.builder() + .host("127.0.0.1") + .password(generateRandomString(8)) + .username("PU4283") + .consumerGroup("EventmeshTest-ConsumerGroup") + .producerGroup("EventmeshTest-ProducerGroup") + .path("/data/app/umg_proxy") + .port(8362) + .subsystem("5023") + .pid(32893) + .version("2.0.11") + .idc("FT") + .build(); } public static UserAgent generateClient2() { - UserAgent user = new UserAgent(); - user.setHost("127.0.0.1"); - user.setPassword(generateRandomString(8)); - user.setUsername("PU4283"); - user.setConsumerGroup("EventmeshTest-ConsumerGroup"); - user.setProducerGroup("EventmeshTest-ProducerGroup"); - user.setPath("/data/app/umg_proxy"); - user.setPort(9362); - user.setSubsystem("5017"); - user.setPid(42893); - user.setVersion("2.0.11"); - user.setIdc("FT"); - return user; + return UserAgent.builder() + .host("127.0.0.1") + .password(generateRandomString(8)) + .username("PU4283") + .consumerGroup("EventmeshTest-ConsumerGroup") + .producerGroup("EventmeshTest-ProducerGroup") + .path("/data/app/umg_proxy") + .port(9362) + .subsystem("5017") + .pid(42893) + .version("2.0.11") + .idc("FT").build(); } public static Package syncRR() { @@ -104,10 +99,10 @@ public static Package rrResponse(Package request) { return msg; } - private static EventMeshMessage generateSyncRRMqMsg() { + public static EventMeshMessage generateSyncRRMqMsg() { EventMeshMessage mqMsg = new EventMeshMessage(); mqMsg.setTopic(TOPIC_PRX_SyncSubscribeTest); - mqMsg.getProperties().put("msgType", "persistent"); + mqMsg.getProperties().put("msgtype", "persistent"); mqMsg.getProperties().put("TTL", "300000"); mqMsg.getProperties().put("KEYS", generateRandomString(16)); mqMsg.setBody("testSyncRR"); @@ -135,7 +130,7 @@ private static EventMeshMessage generateAsyncEventMqMsg() { return mqMsg; } - private static EventMeshMessage generateBroadcastMqMsg() { + public static EventMeshMessage generateBroadcastMqMsg() { EventMeshMessage mqMsg = new EventMeshMessage(); mqMsg.setTopic(TOPIC_PRX_WQ2ClientBroadCast); mqMsg.getProperties().put("REPLY_TO", "10.36.0.109@ProducerGroup-producerPool-9-access#V1_4_0#CI"); diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncPublishBroadcast.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncPublishBroadcast.java deleted file mode 100644 index 0b3d45c728..0000000000 --- a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncPublishBroadcast.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 org.apache.eventmesh.client.tcp.demo; - -import org.apache.eventmesh.client.tcp.EventMeshClient; -import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.client.tcp.common.EventMeshTestUtils; -import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AsyncPublishBroadcast { - - public static Logger logger = LoggerFactory.getLogger(AsyncPublishBroadcast.class); - - private static EventMeshClient client; - - public static void main(String[] agrs) throws Exception { - try { - UserAgent userAgent = EventMeshTestUtils.generateClient1(); - client = new DefaultEventMeshClient("127.0.0.1", 10002, userAgent); - client.init(); - client.heartbeat(); - - Package broadcastMsg = EventMeshTestUtils.broadcastMessage(); - logger.info("begin send broadcast msg============={}", broadcastMsg); - client.broadcast(broadcastMsg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - - Thread.sleep(2000); - // release resource and close client - // client.close(); - } catch (Exception e) { - logger.warn("AsyncPublishBroadcast failed", e); - } - } -} diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncSubscribe.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncSubscribe.java deleted file mode 100644 index abd3ef8a87..0000000000 --- a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncSubscribe.java +++ /dev/null @@ -1,69 +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 org.apache.eventmesh.client.tcp.demo; - - -import io.netty.channel.ChannelHandlerContext; - -import org.apache.eventmesh.client.tcp.EventMeshClient; -import org.apache.eventmesh.client.tcp.common.EventMeshTestUtils; -import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; -import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import org.apache.eventmesh.common.protocol.SubscriptionType; -import org.apache.eventmesh.common.protocol.SubscriptionMode; -import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AsyncSubscribe implements ReceiveMsgHook { - - public static Logger logger = LoggerFactory.getLogger(AsyncSubscribe.class); - - private static EventMeshClient client; - - public static AsyncSubscribe handler = new AsyncSubscribe(); - - public static void main(String[] agrs) throws Exception { - try { - UserAgent userAgent = EventMeshTestUtils.generateClient2(); - client = new DefaultEventMeshClient("127.0.0.1", 10002, userAgent); - client.init(); - client.heartbeat(); - - client.subscribe("TEST-TOPIC-TCP-ASYNC", SubscriptionMode.CLUSTERING, SubscriptionType.ASYNC); - client.registerSubBusiHandler(handler); - - client.listen(); - - //client.unsubscribe(); - - // release resource and close client - // client.close(); - } catch (Exception e) { - logger.warn("AsyncSubscribe failed", e); - } - } - - @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - EventMeshMessage eventMeshMessage = (EventMeshMessage) msg.getBody(); - logger.info("receive async msg====================={}", eventMeshMessage); - } -} diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncSubscribeBroadcast.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncSubscribeBroadcast.java deleted file mode 100644 index 52706c176a..0000000000 --- a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncSubscribeBroadcast.java +++ /dev/null @@ -1,69 +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 org.apache.eventmesh.client.tcp.demo; - - -import io.netty.channel.ChannelHandlerContext; - -import org.apache.eventmesh.client.tcp.EventMeshClient; -import org.apache.eventmesh.client.tcp.common.EventMeshTestUtils; -import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; -import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import org.apache.eventmesh.common.protocol.SubscriptionType; -import org.apache.eventmesh.common.protocol.SubscriptionMode; -import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AsyncSubscribeBroadcast implements ReceiveMsgHook { - - public static Logger logger = LoggerFactory.getLogger(AsyncSubscribeBroadcast.class); - - private static EventMeshClient client; - - public static AsyncSubscribeBroadcast handler = new AsyncSubscribeBroadcast(); - - public static void main(String[] agrs) throws Exception { - try { - UserAgent userAgent = EventMeshTestUtils.generateClient2(); - client = new DefaultEventMeshClient("127.0.0.1", 10002, userAgent); - client.init(); - client.heartbeat(); - - client.subscribe("TEST-TOPIC-TCP-BROADCAST", SubscriptionMode.BROADCASTING, SubscriptionType.ASYNC); - client.registerSubBusiHandler(handler); - - client.listen(); - - //client.unsubscribe(); - - // release resource and close client - // client.close(); - } catch (Exception e) { - logger.warn("AsyncSubscribeBroadcast failed", e); - } - } - - @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - EventMeshMessage eventMeshMessage = (EventMeshMessage) msg.getBody(); - logger.info("receive broadcast msg==============={}", eventMeshMessage); - } -} diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/SyncRequest.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/SyncRequest.java deleted file mode 100644 index 21a28baf1d..0000000000 --- a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/SyncRequest.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 org.apache.eventmesh.client.tcp.demo; - -import org.apache.eventmesh.client.tcp.EventMeshClient; -import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.client.tcp.common.EventMeshTestUtils; -import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SyncRequest { - - public static Logger logger = LoggerFactory.getLogger(SyncRequest.class); - - private static EventMeshClient client; - - public static void main(String[] agrs) throws Exception { - try { - UserAgent userAgent = EventMeshTestUtils.generateClient1(); - client = new DefaultEventMeshClient("127.0.0.1", 10000, userAgent); - client.init(); - client.heartbeat(); - - Package rrMsg = EventMeshTestUtils.syncRR(); - logger.info("begin send rr msg=================={}", rrMsg); - Package response = client.rr(rrMsg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS); - logger.info("receive rr reply==================={}", response); - - // release resource and close client - // client.close(); - } catch (Exception e) { - logger.warn("SyncRequest failed", e); - } - } -} diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/SyncResponse.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/SyncResponse.java deleted file mode 100644 index 96b415ca59..0000000000 --- a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/SyncResponse.java +++ /dev/null @@ -1,69 +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 org.apache.eventmesh.client.tcp.demo; - -import io.netty.channel.ChannelHandlerContext; - -import org.apache.eventmesh.client.tcp.EventMeshClient; -import org.apache.eventmesh.client.tcp.common.EventMeshTestUtils; -import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; -import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import org.apache.eventmesh.common.protocol.SubscriptionType; -import org.apache.eventmesh.common.protocol.SubscriptionMode; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; -import org.apache.eventmesh.common.protocol.tcp.Package; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SyncResponse implements ReceiveMsgHook { - - public static Logger logger = LoggerFactory.getLogger(SyncResponse.class); - - private static EventMeshClient client; - - public static SyncResponse handler = new SyncResponse(); - - public static void main(String[] agrs) throws Exception { - try { - UserAgent userAgent = EventMeshTestUtils.generateClient2(); - client = new DefaultEventMeshClient("127.0.0.1", 10000, userAgent); - client.init(); - client.heartbeat(); - - client.subscribe("TEST-TOPIC-TCP-SYNC", SubscriptionMode.CLUSTERING, SubscriptionType.SYNC); - // Synchronize RR messages - client.registerSubBusiHandler(handler); - - client.listen(); - - //client.unsubscribe(); - - // release resource and close client - // client.close(); - } catch (Exception e) { - logger.warn("SyncResponse failed", e); - } - } - - @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - logger.info("receive sync rr msg================{}", msg); - Package pkg = EventMeshTestUtils.rrResponse(msg); - ctx.writeAndFlush(pkg); - } -} diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/impl/EventMeshTCPClientFactoryTest.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/impl/EventMeshTCPClientFactoryTest.java new file mode 100644 index 0000000000..7e3943105c --- /dev/null +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/impl/EventMeshTCPClientFactoryTest.java @@ -0,0 +1,54 @@ +/* + * Licensed 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.eventmesh.client.tcp.impl; + +import org.apache.eventmesh.client.tcp.EventMeshTCPClient; +import org.apache.eventmesh.client.tcp.EventMeshTCPClientFactory; +import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; +import org.apache.eventmesh.client.tcp.impl.cloudevent.CloudEventTCPClient; +import org.apache.eventmesh.client.tcp.impl.eventmeshmessage.EventMeshMessageTCPClient; +import org.apache.eventmesh.client.tcp.impl.openmessage.OpenMessageTCPClient; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; + +import org.junit.Assert; +import org.junit.Test; + +import io.cloudevents.CloudEvent; +import io.openmessaging.api.Message; + +public class EventMeshTCPClientFactoryTest { + + @Test + public void createEventMeshTCPClient() { + EventMeshTCPClientConfig meshTCPClientConfig = EventMeshTCPClientConfig.builder() + .host("localhost") + .port(1234) + .build(); + EventMeshTCPClient eventMeshMessageTCPClient = + EventMeshTCPClientFactory.createEventMeshTCPClient(meshTCPClientConfig, EventMeshMessage.class); + Assert.assertEquals(EventMeshMessageTCPClient.class, eventMeshMessageTCPClient.getClass()); + + EventMeshTCPClient cloudEventTCPClient = + EventMeshTCPClientFactory.createEventMeshTCPClient(meshTCPClientConfig, CloudEvent.class); + Assert.assertEquals(CloudEventTCPClient.class, cloudEventTCPClient.getClass()); + + EventMeshTCPClient openMessageTCPClient = + EventMeshTCPClientFactory.createEventMeshTCPClient(meshTCPClientConfig, Message.class); + Assert.assertEquals(OpenMessageTCPClient.class, openMessageTCPClient.getClass()); + } +} \ No newline at end of file diff --git a/eventmesh-security-plugin/eventmesh-security-acl/build.gradle b/eventmesh-security-plugin/eventmesh-security-acl/build.gradle index af9362ecd9..1ee3c750ab 100644 --- a/eventmesh-security-plugin/eventmesh-security-acl/build.gradle +++ b/eventmesh-security-plugin/eventmesh-security-acl/build.gradle @@ -16,7 +16,7 @@ */ dependencies { - compileOnly project(":eventmesh-security-plugin:eventmesh-security-api") + implementation project(":eventmesh-security-plugin:eventmesh-security-api") testImplementation project(":eventmesh-security-plugin:eventmesh-security-api") } diff --git a/eventmesh-security-plugin/eventmesh-security-api/build.gradle b/eventmesh-security-plugin/eventmesh-security-api/build.gradle index 594503e74f..0d410425ba 100644 --- a/eventmesh-security-plugin/eventmesh-security-api/build.gradle +++ b/eventmesh-security-plugin/eventmesh-security-api/build.gradle @@ -16,7 +16,7 @@ */ dependencies { - implementation project(":eventmesh-spi") + api project(":eventmesh-spi") testImplementation project(":eventmesh-spi") } diff --git a/eventmesh-spi/build.gradle b/eventmesh-spi/build.gradle index 7c61ebcf9d..4980522b47 100644 --- a/eventmesh-spi/build.gradle +++ b/eventmesh-spi/build.gradle @@ -15,6 +15,7 @@ * limitations under the License. */ dependencies { - compileOnly project(":eventmesh-common") + implementation project(":eventmesh-common") + implementation "org.apache.commons:commons-collections4" testImplementation project(":eventmesh-common") } \ No newline at end of file diff --git a/eventmesh-starter/build.gradle b/eventmesh-starter/build.gradle index 48aafcb72d..0bc2208fd1 100644 --- a/eventmesh-starter/build.gradle +++ b/eventmesh-starter/build.gradle @@ -17,6 +17,4 @@ dependencies { implementation project(":eventmesh-runtime") - testImplementation project(":eventmesh-runtime") - //testImplementation group: 'junit', name: 'junit', version: '4.12' } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 73dc286f04..d51e958500 100644 --- a/gradle.properties +++ b/gradle.properties @@ -30,3 +30,5 @@ apacheUserName= #apache password apachePassWord= signEnabled=false + +org.gradle.warning.mode=none diff --git a/settings.gradle b/settings.gradle index 2bf9859260..9916d681ca 100644 --- a/settings.gradle +++ b/settings.gradle @@ -29,7 +29,6 @@ include 'eventmesh-connector-plugin:eventmesh-connector-standalone' include 'eventmesh-security-plugin:eventmesh-security-api' include 'eventmesh-security-plugin:eventmesh-security-acl' include 'eventmesh-registry-plugin:eventmesh-registry-api' -include 'eventmesh-registry-plugin:eventmesh-registry-namesrv' include 'eventmesh-admin' include 'eventmesh-schema-registry' include 'eventmesh-schema-registry:eventmesh-schema-registry-server' @@ -37,5 +36,9 @@ include 'eventmesh-protocol-plugin' include 'eventmesh-protocol-plugin:eventmesh-protocol-api' include 'eventmesh-protocol-plugin:eventmesh-protocol-openmessage' include 'eventmesh-protocol-plugin:eventmesh-protocol-cloudevents' +include 'eventmesh-protocol-plugin:eventmesh-protocol-meshmessage' +include 'eventmesh-admin:eventmesh-admin-rocketmq' include 'eventmesh-protocol-plugin:eventmesh-protocol-grpc' +include 'eventmesh-protocol-plugin:eventmesh-protocol-grpcmessage' +findProject(':eventmesh-protocol-plugin:eventmesh-protocol-grpcmessage')?.name = 'eventmesh-protocol-grpcmessage' diff --git a/style/checkStyle.xml b/style/checkStyle.xml index 9e86d5537d..f3fe5630d2 100644 --- a/style/checkStyle.xml +++ b/style/checkStyle.xml @@ -54,7 +54,7 @@ - + @@ -263,7 +263,6 @@ - @@ -315,15 +314,6 @@ - - - - - - - - "$self_modules_txt" + +find "$decompress_conf" -name "*.jar" -exec basename {} \; | uniq | sort > "$all_dependencies_txt" + +grep -wvf "$self_modules_txt" "$all_dependencies_txt" | uniq | sort > "$third_party_dependencies_txt" + +# If the check is success it will return 0 +diff -w -B "$third_party_dependencies_txt" "$known_third_party_dependencies_txt" + diff --git a/tools/third-party-dependencies/known-dependencies.txt b/tools/third-party-dependencies/known-dependencies.txt new file mode 100644 index 0000000000..244ee24b3d --- /dev/null +++ b/tools/third-party-dependencies/known-dependencies.txt @@ -0,0 +1,79 @@ +assertj-core-2.6.0.jar +checker-qual-2.11.1.jar +cloudevents-api-2.2.0.jar +cloudevents-core-2.2.0.jar +cloudevents-json-jackson-2.2.0.jar +commons-beanutils-1.9.2.jar +commons-cli-1.2.jar +commons-codec-1.9.jar +commons-collections-3.2.2.jar +commons-collections4-4.1.jar +commons-digester-1.8.1.jar +commons-lang3-3.6.jar +commons-logging-1.2.jar +commons-text-1.9.jar +commons-validator-1.6.jar +disruptor-3.4.2.jar +dledger-0.1.jar +error_prone_annotations-2.3.4.jar +failureaccess-1.0.1.jar +fastjson-1.2.69.jar +guava-29.0-jre.jar +hamcrest-core-1.3.jar +httpclient-4.5.2.jar +httpcore-4.4.4.jar +j2objc-annotations-1.3.jar +jackson-annotations-2.11.0.jar +jackson-core-2.11.0.jar +jackson-databind-2.11.0.jar +javassist-3.20.0-GA.jar +jcommander-1.72.jar +jna-4.2.2.jar +jsr305-3.0.2.jar +junit-4.12.jar +listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar +log4j-api-2.16.0.jar +log4j-core-2.16.0.jar +log4j-slf4j-impl-2.16.0.jar +logback-core-1.0.13.jar +metrics-annotation-4.1.0.jar +metrics-core-4.1.0.jar +metrics-healthchecks-4.1.0.jar +metrics-json-4.1.0.jar +netty-all-4.1.49.Final.jar +netty-tcnative-boringssl-static-1.1.33.Fork26.jar +okhttp-3.14.9.jar +okio-1.17.2.jar +openmessaging-api-2.2.1-pubsub.jar +opentelemetry-api-1.3.0.jar +opentelemetry-api-metrics-1.3.0-alpha.jar +opentelemetry-context-1.3.0.jar +opentelemetry-exporter-prometheus-1.3.0-alpha.jar +opentelemetry-exporter-zipkin-1.3.0.jar +opentelemetry-sdk-1.3.0.jar +opentelemetry-sdk-common-1.3.0.jar +opentelemetry-sdk-metrics-1.3.0-alpha.jar +opentelemetry-sdk-trace-1.3.0.jar +opentelemetry-semconv-1.3.0-alpha.jar +rocketmq-acl-4.7.1.jar +rocketmq-broker-4.7.1.jar +rocketmq-client-4.7.1.jar +rocketmq-common-4.7.1.jar +rocketmq-filter-4.7.1.jar +rocketmq-logging-4.7.1.jar +rocketmq-namesrv-4.7.1.jar +rocketmq-remoting-4.7.1.jar +rocketmq-srvutil-4.7.1.jar +rocketmq-store-4.7.1.jar +rocketmq-test-4.7.1.jar +rocketmq-tools-4.7.1.jar +simpleclient-0.8.1.jar +simpleclient_common-0.8.1.jar +simpleclient_httpserver-0.8.1.jar +slf4j-api-1.7.30.jar +snakeyaml-1.19.jar +system-rules-1.16.1.jar +truth-0.30.jar +zipkin-2.23.2.jar +zipkin-reporter-2.16.3.jar +zipkin-sender-okhttp3-2.16.3.jar \ No newline at end of file diff --git a/tools/third-party-licenses/LICENSE b/tools/third-party-licenses/LICENSE new file mode 100644 index 0000000000..ca49b456ba --- /dev/null +++ b/tools/third-party-licenses/LICENSE @@ -0,0 +1,336 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + +======================================================================= +Apache EventMesh (incubating) Subcomponents: + +The Apache EventMesh (incubating) project contains subcomponents with separate copyright +notices and license terms. Your use of the source code for the these +subcomponents is subject to the terms and conditions of the following +licenses. + +======================================================================== +Apache 2.0 licenses +======================================================================== + +The following components are provided under the Apache License. See project link for details. +The text of each license is also included at licenses/LICENSE-[project].txt. + +assertj-core 2.6.0: https://github.com/assertj/assertj-core, Apache 2.0 +cloudevents-api 2.2.0: https://github.com/cloudevents/sdk-java, Apache 2.0 +cloudevents-core 2.2.0: https://github.com/cloudevents/sdk-java, Apache 2.0 +cloudevents-json-jackson 2.2.0: https://github.com/cloudevents/sdk-java, Apache 2.0 +commons-beanutils 1.9.2: https://github.com/apache/commons-beanutils, Apache 2.0 +commons-cli 1.2: https://github.com/apache/commons-cli, Apache 2.0 +commons-codec 1.9: https://github.com/apache/commons-codec, Apache 2.0 +commons-collections 3.2.2: https://github.com/apache/commons-collections, Apache 2.0 +commons-collections4 4.1: https://github.com/apache/commons-collections, Apache 2.0 +commons-digester 1.8.1: https://github.com/apache/commons-digester, Apache 2.0 +commons-lang3 3.6: https://github.com/apache/commons-lang, Apache 2.0 +commons-logging 1.2: https://github.com/apache/commons-logging, Apache 2.0 +commons-text 1.9: https://github.com/apache/commons-text, Apache 2.0 +commons-validator 1.6: https://github.com/apache/commons-validator, Apache 2.0 +disruptor 3.4.2: https://github.com/LMAX-Exchange/disruptor, Apache 2.0 +dledger 0.1: https://github.com/openmessaging/dledger, Apache 2.0 +error_prone_annotations 2.3.4: https://github.com/google/error-prone, Apache 2.0 +failureaccess 1.0.1: https://github.com/google/guava, Apache 2.0 +listenablefuture 9999.0-empty-to-avoid-conflict-with-guava: https://github.com/google/guava, Apache 2.0 +fastjson 1.2.69: https://github.com/alibaba/fastjson, Apache 2.0 +guava 29.0-jre: https://github.com/google/guava, Apache 2.0 +httpclient 4.5.2: https://github.com/apache/httpcomponents-client, Apache 2.0 +httpcore 4.4.4: https://github.com/apache/httpcomponents-core, Apache 2.0 +j2objc-annotations 1.3: https://github.com/google/j2objc, Apache 2.0 +jackson-annotations 2.11.0: https://github.com/FasterXML/jackson-annotations, Apache 2.0 +jackson-core 2.11.0:https://github.com/FasterXML/jackson-core, Apache 2.0 +jackson-databind 2.11.0: https://github.com/FasterXML/jackson-databind, Apache 2.0 +javassist 3.20.0-GA/3.24.0-GA: https://github.com/jboss-javassist/javassist, Apache 2.0 +jcommander 1.72: https://github.com/cbeust/jcommander, Apache 2.0 +jna 4.2.2: https://github.com/java-native-access/jna, Apache 2.0 +log4j-api 2.16.0: https://github.com/apache/log4j, Apache 2.0 +log4j-core 2.16.0: https://github.com/apache/log4j, Apache 2.0 +metrics-annotation 4.1.0: https://github.com/dropwizard/metrics, Apache 2.0 +metrics-core 4.1.0: https://github.com/dropwizard/metrics, Apache 2.0 +metrics-healthchecks 4.1.0: https://github.com/dropwizard/metrics, Apache 2.0 +metrics-json 4.1.0: https://github.com/dropwizard/metrics, Apache 2.0 +netty-all 4.1.49.Final: https://github.com/netty/netty, Apache 2.0 +netty-tcnative-boringssl-static 1.1.33.Fork26: https://github.com/netty/netty, Apache 2.0 +okio 1.17.2: https://github.com/square/okio, Apache 2.0 +okhttp 3.14.9: https://github.com/square/okhttp +openmessaging-api 2.22.1-pubsub: https://github.com/openmessaging/dledger, Apache 2.0 +opentelemetry-api 1.3.0: https://github.com/open-telemetry/opentelemetry-java, Apache 2.0 +opentelemetry-api-metrics 1.3.0-alpha: https://github.com/open-telemetry/opentelemetry-java, Apache 2.0 +opentelemetry-context 1.3.0: https://github.com/open-telemetry/opentelemetry-java, Apache 2.0 +opentelemetry-exporter-prometheus 1.3.0-alpha: https://github.com/open-telemetry/opentelemetry-java, Apache 2.0 +opentelemetry-exporter-zipkin 1.3.0: https://github.com/open-telemetry/opentelemetry-java, Apache 2.0 +opentelemetry-sdk 1.3.0: https://github.com/open-telemetry/opentelemetry-java, Apache 2.0 +opentelemetry-sdk-common 1.3.0: https://github.com/open-telemetry/opentelemetry-java, Apache 2.0 +opentelemetry-sdk-metrics 1.3.0-alpha: https://github.com/open-telemetry/opentelemetry-java, Apache 2.0 +opentelemetry-sdk-trace 1.3.0: https://github.com/open-telemetry/opentelemetry-java, Apache 2.0 +opentelemetry-semconv 1.3.0-alpha: https://github.com/open-telemetry/opentelemetry-java, Apache 2.0 +rocketmq-acl 4.7.1: https://github.com/apache/rocketmq, Apache 2.0 +rocketmq-broker 4.7.1: https://github.com/apache/rocketmq, Apache 2.0 +rocketmq-client 4.7.1: https://github.com/apache/rocketmq, Apache 2.0 +rocketmq-common 4.7.1: https://github.com/apache/rocketmq, Apache 2.0 +rocketmq-filter 4.7.1: https://github.com/apache/rocketmq, Apache 2.0 +rocketmq-logging 4.7.1: https://github.com/apache/rocketmq, Apache 2.0 +rocketmq-namesrv 4.7.1: https://github.com/apache/rocketmq, Apache 2.0 +rocketmq-remoting 4.7.1: https://github.com/apache/rocketmq, Apache 2.0 +rocketmq-srvutil 4.7.1: https://github.com/apache/rocketmq, Apache 2.0 +rocketmq-store 4.7.1: https://github.com/apache/rocketmq, Apache 2.0 +rocketmq-test 4.7.1: https://github.com/apache/rocketmq, Apache 2.0 +rocketmq-tools 4.7.1: https://github.com/apache/rocketmq, Apache 2.0 +simpleclient 0.8.1: https://github.com/prometheus/client_java, Apache 2.0 +simpleclient_common 0.8.1: https://github.com/prometheus/client_java, Apache 2.0 +simpleclient_httpserver 0.8.1: https://github.com/prometheus/client_java, Apache 2.0 +snakeyaml 1.19/1.23: https://bitbucket.org/asomov/snakeyaml, Apache 2.0 +truth 0.30: https://github.com/google/truth, Apache 2.0 +zipkin 2.23.2: https://github.com/openzipkin/zipkin, Apache 2.0 +zipkin-reporter 2.16.3: https://github.com/openzipkin/zipkin-reporter-java, Apache 2.0 +zipkin-sender-okhttp3 2.16.3: https://github.com/openzipkin/zipkin-reporter-java, Apache 2.0 + +======================================================================== +BSD licenses +======================================================================== + +The following components are provided under a BSD license. See project link for details. +The text of each license is also included at licenses/LICENSE-[project].txt. + +hamcrest-core 1.3: https://github.com/hamcrest/JavaHamcrest, BSD +jsr305 3.0.2: https://code.google.com/archive/p/jsr-305, BSD + +======================================================================== +CDDL licenses +======================================================================== + +The following components are provided under the CDDL License. See project link for details. +The text of each license is also included at licenses/LICENSE-[project].txt. + + +======================================================================== +CPL licenses +======================================================================== + +The following components are provided under the CPL License. See project link for details. +The text of each license is also included at licenses/LICENSE-[project].txt. + +system-rules 1.16.1: https://github.com/stefanbirkner/system-rules + +======================================================================== +EPL licenses +======================================================================== + +The following components are provided under the EPL License. See project link for details. +The text of each license is also included at licenses/LICENSE-[project].txt. + +junit 4.12: https://github.com/junit-team/junit5, EPL +logback-core 1.0.13: https://github.com/qos-ch/logback, EPL + +======================================================================== +MIT licenses +======================================================================== + +The following components are provided under the MIT license. See project link for details. +The text of each license is also included at licenses/LICENSE-[project].txt. + +checker-qual 2.11.1: https://github.com/typetools/checker-framework, MIT +log4j-slf4j-impl 2.16.0: https://github.com/qos-ch/slf4j, MIT +slf4j-api 1.7.30: https://github.com/qos-ch/slf4j, MIT diff --git a/tools/third-party-licenses/licenses/LICENSE-assertj-core.txt b/tools/third-party-licenses/licenses/LICENSE-assertj-core.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-assertj-core.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-checker-qual.txt b/tools/third-party-licenses/licenses/LICENSE-checker-qual.txt new file mode 100644 index 0000000000..f490f98ba6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-checker-qual.txt @@ -0,0 +1,413 @@ +The Checker Framework +Copyright 2004-present by the Checker Framework developers + + +Most of the Checker Framework is licensed under the GNU General Public +License, version 2 (GPL2), with the classpath exception. The text of this +license appears below. This is the same license used for OpenJDK. + +A few parts of the Checker Framework have more permissive licenses. + + * The annotations are licensed under the MIT License. (The text of this + license appears below.) More specifically, all the parts of the Checker + Framework that you might want to include with your own program use the + MIT License. This is the checker-qual.jar file and all the files that + appear in it: every file in a qual/ directory, plus utility files such + as NullnessUtil.java, RegexUtil.java, SignednessUtil.java, etc. + In addition, the cleanroom implementations of third-party annotations, + which the Checker Framework recognizes as aliases for its own + annotations, are licensed under the MIT License. + +Some external libraries that are included with the Checker Framework have +different licenses. + + * javaparser is dual licensed under the LGPL or the Apache license -- you + may use it under whichever one you want. (The javaparser source code + contains a file with the text of the GPL, but it is not clear why, since + javaparser does not use the GPL.) See file stubparser/LICENSE + and the source code of all its files. + + * JUnit is licensed under the Common Public License v1.0 (see + http://www.junit.org/license), with parts (Hamcrest) licensed under the + BSD License (see http://hamcrest.org/JavaHamcrest/). + + * Libraries in plume-lib (https://github.com/plume-lib/) are licensed + under the MIT License. + +The Checker Framework includes annotations for the JDK in directory +checker/jdk/, and for some other libraries. Each annotated library uses +the same license as the unannotated version of the library. + +=========================================================================== + +The GNU General Public License (GPL) + +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public License is intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. This General Public License applies to +most of the Free Software Foundation's software and to any other program whose +authors commit to using it. (Some other Free Software Foundation software is +covered by the GNU Library General Public License instead.) You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the freedom to +distribute copies of free software (and charge for this service if you wish), +that you receive source code or can get it if you want it, that you can change +the software or use pieces of it in new free programs; and that you know you +can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny +you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of the +software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for +a fee, you must give the recipients all the rights that you have. You must +make sure that they, too, receive or can get the source code. And you must +show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) +offer you this license which gives you legal permission to copy, distribute +and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If the +software is modified by someone else and passed on, we want its recipients to +know that what they have is not the original, so that any problems introduced +by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that redistributors of a free program will +individually obtain patent licenses, in effect making the program proprietary. +To prevent this, we have made it clear that any patent must be licensed for +everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification +follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms of +this General Public License. The "Program", below, refers to any such program +or work, and a "work based on the Program" means either the Program or any +derivative work under copyright law: that is to say, a work containing the +Program or a portion of it, either verbatim or with modifications and/or +translated into another language. (Hereinafter, translation is included +without limitation in the term "modification".) Each licensee is addressed as +"you". + +Activities other than copying, distribution and modification are not covered by +this License; they are outside its scope. The act of running the Program is +not restricted, and the output from the Program is covered only if its contents +constitute a work based on the Program (independent of having been made by +running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as +you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this License +and to the absence of any warranty; and give any other recipients of the +Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may +at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus +forming a work based on the Program, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all of +these conditions: + + a) You must cause the modified files to carry prominent notices stating + that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or + in part contains or is derived from the Program or any part thereof, to be + licensed as a whole at no charge to all third parties under the terms of + this License. + + c) If the modified program normally reads commands interactively when run, + you must cause it, when started running for such interactive use in the + most ordinary way, to print or display an announcement including an + appropriate copyright notice and a notice that there is no warranty (or + else, saying that you provide a warranty) and that users may redistribute + the program under these conditions, and telling the user how to view a copy + of this License. (Exception: if the Program itself is interactive but does + not normally print such an announcement, your work based on the Program is + not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be reasonably +considered independent and separate works in themselves, then this License, and +its terms, do not apply to those sections when you distribute them as separate +works. But when you distribute the same sections as part of a whole which is a +work based on the Program, the distribution of the whole must be on the terms +of this License, whose permissions for other licensees extend to the entire +whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise the +right to control the distribution of derivative or collective works based on +the Program. + +In addition, mere aggregation of another work not based on the Program with the +Program (or with a work based on the Program) on a volume of a storage or +distribution medium does not bring the other work under the scope of this +License. + +3. You may copy and distribute the Program (or a work based on it, under +Section 2) in object code or executable form under the terms of Sections 1 and +2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source + code, which must be distributed under the terms of Sections 1 and 2 above + on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to + give any third party, for a charge no more than your cost of physically + performing source distribution, a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of Sections 1 + and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to + distribute corresponding source code. (This alternative is allowed only + for noncommercial distribution and only if you received the program in + object code or executable form with such an offer, in accord with + Subsection b above.) + +The source code for a work means the preferred form of the work for making +modifications to it. For an executable work, complete source code means all +the source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and installation +of the executable. However, as a special exception, the source code +distributed need not include anything that is normally distributed (in either +source or binary form) with the major components (compiler, kernel, and so on) +of the operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the source +code from the same place counts as distribution of the source code, even though +third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as +expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense or distribute the Program is void, and will automatically terminate +your rights under this License. However, parties who have received copies, or +rights, from you under this License will not have their licenses terminated so +long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. +However, nothing else grants you permission to modify or distribute the Program +or its derivative works. These actions are prohibited by law if you do not +accept this License. Therefore, by modifying or distributing the Program (or +any work based on the Program), you indicate your acceptance of this License to +do so, and all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), +the recipient automatically receives a license from the original licensor to +copy, distribute or modify the Program subject to these terms and conditions. +You may not impose any further restrictions on the recipients' exercise of the +rights granted herein. You are not responsible for enforcing compliance by +third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), conditions +are imposed on you (whether by court order, agreement or otherwise) that +contradict the conditions of this License, they do not excuse you from the +conditions of this License. If you cannot distribute so as to satisfy +simultaneously your obligations under this License and any other pertinent +obligations, then as a consequence you may not distribute the Program at all. +For example, if a patent license would not permit royalty-free redistribution +of the Program by all those who receive copies directly or indirectly through +you, then the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply and +the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or +other property right claims or to contest validity of any such claims; this +section has the sole purpose of protecting the integrity of the free software +distribution system, which is implemented by public license practices. Many +people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose that +choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original +copyright holder who places the Program under this License may add an explicit +geographical distribution limitation excluding those countries, so that +distribution is permitted only in or among countries not thus excluded. In +such case, this License incorporates the limitation as if written in the body +of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the +General Public License from time to time. Such new versions will be similar in +spirit to the present version, but may differ in detail to address new problems +or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any later +version", you have the option of following the terms and conditions either of +that version or of any later version published by the Free Software Foundation. +If the Program does not specify a version number of this License, you may +choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, +write to the Free Software Foundation; we sometimes make exceptions for this. +Our decision will be guided by the two goals of preserving the free status of +all derivatives of our free software and of promoting the sharing and reuse of +software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE +PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, +YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL +ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE +PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR +INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA +BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER +OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible +use to the public, the best way to achieve this is to make it free software +which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach +them to the start of each source file to most effectively convey the exclusion +of warranty; and each file should have at least the "copyright" line and a +pointer to where the full notice is found. + + One line to give the program's name and a brief idea of what it does. + + Copyright (C) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., 59 + Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it +starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes + with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free + software, and you are welcome to redistribute it under certain conditions; + type 'show c' for details. + +The hypothetical commands 'show w' and 'show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may be +called something other than 'show w' and 'show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the program, if necessary. Here +is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + 'Gnomovision' (which makes passes at compilers) written by James Hacker. + + signature of Ty Coon, 1 April 1989 + + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General Public +License instead of this License. + + +"CLASSPATH" EXCEPTION TO THE GPL + +Certain source files distributed by Oracle America and/or its affiliates are +subject to the following clarification and special exception to the GPL, but +only where Oracle has expressly included in the particular source file's header +the words "Oracle designates this particular file as subject to the "Classpath" +exception as provided by Oracle in the LICENSE file that accompanied this code." + + Linking this library statically or dynamically with other modules is making + a combined work based on this library. Thus, the terms and conditions of + the GNU General Public License cover the whole combination. + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent modules, + and to copy and distribute the resulting executable under terms of your + choice, provided that you also meet, for each linked independent module, + the terms and conditions of the license of that module. An independent + module is a module which is not derived from or based on this library. If + you modify this library, you may extend this exception to your version of + the library, but you are not obligated to do so. If you do not wish to do + so, delete this exception statement from your version. + +=========================================================================== + +MIT License: + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +=========================================================================== \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-cloudevents-api.txt b/tools/third-party-licenses/licenses/LICENSE-cloudevents-api.txt new file mode 100644 index 0000000000..1a7891acd6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-cloudevents-api.txt @@ -0,0 +1,203 @@ + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018-Present The CloudEvents Authors + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-cloudevents-core.txt b/tools/third-party-licenses/licenses/LICENSE-cloudevents-core.txt new file mode 100644 index 0000000000..1a7891acd6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-cloudevents-core.txt @@ -0,0 +1,203 @@ + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018-Present The CloudEvents Authors + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-cloudevents-json-jackson.txt b/tools/third-party-licenses/licenses/LICENSE-cloudevents-json-jackson.txt new file mode 100644 index 0000000000..1a7891acd6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-cloudevents-json-jackson.txt @@ -0,0 +1,203 @@ + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018-Present The CloudEvents Authors + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-commons-beanutils.txt b/tools/third-party-licenses/licenses/LICENSE-commons-beanutils.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-commons-beanutils.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-commons-cli.txt b/tools/third-party-licenses/licenses/LICENSE-commons-cli.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-commons-cli.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-commons-codec.txt b/tools/third-party-licenses/licenses/LICENSE-commons-codec.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-commons-codec.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-commons-collections.txt b/tools/third-party-licenses/licenses/LICENSE-commons-collections.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-commons-collections.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-commons-collections4.txt b/tools/third-party-licenses/licenses/LICENSE-commons-collections4.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-commons-collections4.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-commons-digester.txt b/tools/third-party-licenses/licenses/LICENSE-commons-digester.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-commons-digester.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-commons-lang3.txt b/tools/third-party-licenses/licenses/LICENSE-commons-lang3.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-commons-lang3.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-commons-logging.txt b/tools/third-party-licenses/licenses/LICENSE-commons-logging.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-commons-logging.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-commons-text.txt b/tools/third-party-licenses/licenses/LICENSE-commons-text.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-commons-text.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-commons-validator.txt b/tools/third-party-licenses/licenses/LICENSE-commons-validator.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-commons-validator.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-disruptor.txt b/tools/third-party-licenses/licenses/LICENSE-disruptor.txt new file mode 100644 index 0000000000..50086f8b44 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-disruptor.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-dledger.txt b/tools/third-party-licenses/licenses/LICENSE-dledger.txt new file mode 100644 index 0000000000..b90520c005 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-dledger.txt @@ -0,0 +1,203 @@ + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (properties) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017-2020 the original author or authors + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-error_prone_annotations.txt b/tools/third-party-licenses/licenses/LICENSE-error_prone_annotations.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-error_prone_annotations.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-failureaccess.txt b/tools/third-party-licenses/licenses/LICENSE-failureaccess.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-failureaccess.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-fastjson.txt b/tools/third-party-licenses/licenses/LICENSE-fastjson.txt new file mode 100644 index 0000000000..59f9c59414 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-fastjson.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 1999-2019 Alibaba Group Holding Ltd. + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-guava.txt b/tools/third-party-licenses/licenses/LICENSE-guava.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-guava.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-hamcrest-core.txt b/tools/third-party-licenses/licenses/LICENSE-hamcrest-core.txt new file mode 100644 index 0000000000..0bf62645cf --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-hamcrest-core.txt @@ -0,0 +1,27 @@ +BSD License + +Copyright (c) 2000-2015 www.hamcrest.org +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. Redistributions in binary form must reproduce +the above copyright notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the distribution. + +Neither the name of Hamcrest nor the names of its contributors may be used to endorse +or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-httpclient.txt b/tools/third-party-licenses/licenses/LICENSE-httpclient.txt new file mode 100644 index 0000000000..437923f350 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-httpclient.txt @@ -0,0 +1,558 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + +========================================================================= + +This project includes Public Suffix List copied from + +licensed under the terms of the Mozilla Public License, v. 2.0 + +Full license text: + +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-httpcore.txt b/tools/third-party-licenses/licenses/LICENSE-httpcore.txt new file mode 100644 index 0000000000..4947287f7b --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-httpcore.txt @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-j2objc-annotations.txt b/tools/third-party-licenses/licenses/LICENSE-j2objc-annotations.txt new file mode 100644 index 0000000000..2b004c3eee --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-j2objc-annotations.txt @@ -0,0 +1,232 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + +-------------------------------------------------------------------------------- +The next section, BSD-3-Clause, applies to the files in: +jre_emul/android/platform/libcore/ojluni/src/main/java/java/time +-------------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of JSR-310 nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-jackson-annotations.txt b/tools/third-party-licenses/licenses/LICENSE-jackson-annotations.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-jackson-annotations.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-jackson-core.txt b/tools/third-party-licenses/licenses/LICENSE-jackson-core.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-jackson-core.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-jackson-databind.txt b/tools/third-party-licenses/licenses/LICENSE-jackson-databind.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-jackson-databind.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-javassist.txt b/tools/third-party-licenses/licenses/LICENSE-javassist.txt new file mode 100644 index 0000000000..a8d8dfd737 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-javassist.txt @@ -0,0 +1,141 @@ +MOZILLA PUBLIC LICENSE +Version 1.1 +1. Definitions. + +1.0.1. "Commercial Use" means distribution or otherwise making the Covered Code available to a third party. +1.1. ''Contributor'' means each entity that creates or contributes to the creation of Modifications. + +1.2. ''Contributor Version'' means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor. + +1.3. ''Covered Code'' means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof. + +1.4. ''Electronic Distribution Mechanism'' means a mechanism generally accepted in the software development community for the electronic transfer of data. + +1.5. ''Executable'' means Covered Code in any form other than Source Code. + +1.6. ''Initial Developer'' means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A. + +1.7. ''Larger Work'' means a work which combines Covered Code or portions thereof with code not governed by the terms of this License. + +1.8. ''License'' means this document. + +1.8.1. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. + +1.9. ''Modifications'' means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is: + +A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications. +B. Any new file that contains any part of the Original Code or previous Modifications. + + +1.10. ''Original Code'' means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License. +1.10.1. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. + +1.11. ''Source Code'' means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge. + +1.12. "You'' (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You'' includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control'' means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. + +2. Source Code License. +2.1. The Initial Developer Grant. +The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: +(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, and/or as part of a Larger Work; and +(b) under Patents Claims infringed by the making, using or selling of Original Code, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Code (or portions thereof). + +(c) the licenses granted in this Section 2.1(a) and (b) are effective on the date Initial Developer first distributes Original Code under the terms of this License. +(d) Notwithstanding Section 2.1(b) above, no patent license is granted: 1) for code that You delete from the Original Code; 2) separate from the Original Code; or 3) for infringements caused by: i) the modification of the Original Code or ii) the combination of the Original Code with other software or devices. + + +2.2. Contributor Grant. +Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license + +(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor, to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code and/or as part of a Larger Work; and +(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications made by that Contributor (or portions thereof); and 2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). + +(c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first makes Commercial Use of the Covered Code. + +(d) Notwithstanding Section 2.2(b) above, no patent license is granted: 1) for any code that Contributor has deleted from the Contributor Version; 2) separate from the Contributor Version; 3) for infringements caused by: i) third party modifications of Contributor Version or ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or 4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor. + + +3. Distribution Obligations. + +3.1. Application of License. +The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. +3.2. Availability of Source Code. +Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. + +3.3. Description of Modifications. +You must cause all Covered Code to which You contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code. + +3.4. Intellectual Property Matters + +(a) Third Party Claims. +If Contributor has knowledge that a license under a third party's intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled "LEGAL'' which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained. +(b) Contributor APIs. +If Contributor's Modifications include an application programming interface and Contributor has knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the LEGAL file. + + + (c) Representations. +Contributor represents that, except as disclosed pursuant to Section 3.4(a) above, Contributor believes that Contributor's Modifications are Contributor's original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License. + +3.5. Required Notices. +You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients' rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. + +3.6. Distribution of Executable Versions. +You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. + +3.7. Larger Works. +You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. +If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. +5. Application of this License. +This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code. +6. Versions of the License. +6.1. New Versions. +Netscape Communications Corporation (''Netscape'') may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number. +6.2. Effect of New Versions. +Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Netscape. No one other than Netscape has the right to modify the terms applicable to Covered Code created under this License. + +6.3. Derivative Works. +If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must (a) rename Your license so that the phrases ''Mozilla'', ''MOZILLAPL'', ''MOZPL'', ''Netscape'', "MPL", ''NPL'' or any confusingly similar phrase do not appear in your license (except to note that your license differs from this License) and (b) otherwise make it clear that Your version of the license contains terms which differ from the Mozilla Public License and Netscape Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.) + +7. DISCLAIMER OF WARRANTY. +COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS'' BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. +8. TERMINATION. +8.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. +8.2. If You initiate litigation by asserting a patent infringement claim (excluding declatory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You file such action is referred to as "Participant") alleging that: + +(a) such Participant's Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either: (i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or (ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant. If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above. + +(b) any software, hardware, or device, other than such Participant's Contributor Version, directly or indirectly infringes any patent, then any rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective as of the date You first made, used, sold, distributed, or had made, Modifications made by that Participant. + +8.3. If You assert a patent infringement claim against Participant alleging that such Participant's Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license. + +8.4. In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination. + +9. LIMITATION OF LIABILITY. +UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. +10. U.S. GOVERNMENT END USERS. +The Covered Code is a ''commercial item,'' as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of ''commercial computer software'' and ''commercial computer software documentation,'' as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein. +11. MISCELLANEOUS. +This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in the United States of America, any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. +12. RESPONSIBILITY FOR CLAIMS. +As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. +13. MULTIPLE-LICENSED CODE. +Initial Developer may designate portions of the Covered Code as "Multiple-Licensed". "Multiple-Licensed" means that the Initial Developer permits you to utilize portions of the Covered Code under Your choice of the MPL or the alternative licenses, if any, specified by the Initial Developer in the file described in Exhibit A. + +EXHIBIT A -Mozilla Public License. + +The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/ +Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF +ANY KIND, either express or implied. See the License for the specific language governing rights and +limitations under the License. + +The Original Code is Javassist. + +The Initial Developer of the Original Code is Shigeru Chiba. Portions created by the Initial Developer are + Copyright (C) 1999- Shigeru Chiba. All Rights Reserved. + +Contributor(s): __Bill Burke, Jason T. Greene______________. + +Alternatively, the contents of this software may be used under the terms of the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), or the Apache License Version 2.0 (the "AL"), in which case the provisions of the LGPL or the AL are applicable instead of those above. If you wish to allow use of your version of this software only under the terms of either the LGPL or the AL, and not to allow others to use your version of this software under the terms of the MPL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the LGPL or the AL. If you do not delete the provisions above, a recipient may use your version of this software under the terms of any one of the MPL, the LGPL or the AL. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-jcommander.txt b/tools/third-party-licenses/licenses/LICENSE-jcommander.txt new file mode 100644 index 0000000000..477eb7b7ba --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-jcommander.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2012, Cedric Beust + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-jna.txt b/tools/third-party-licenses/licenses/LICENSE-jna.txt new file mode 100644 index 0000000000..b456098518 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-jna.txt @@ -0,0 +1,26 @@ +SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1 + +Java Native Access (JNA) is licensed under the LGPL, version 2.1 +or later, or (from version 4.0 onward) the Apache License, +version 2.0. + +You can freely decide which license you want to apply to the project. + +You may obtain a copy of the LGPL License at: + +http://www.gnu.org/licenses/licenses.html + +A copy is also included in the downloadable source code package +containing JNA, in file "LGPL2.1", under the same directory +as this file. + +You may obtain a copy of the Apache License at: + +http://www.apache.org/licenses/ + +A copy is also included in the downloadable source code package +containing JNA, in file "AL2.0", under the same directory +as this file. + +Commercial support may be available, please e-mail +twall[at]users[dot]sf[dot]net. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-jsr305.txt b/tools/third-party-licenses/licenses/LICENSE-jsr305.txt new file mode 100644 index 0000000000..7fb51fb895 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-jsr305.txt @@ -0,0 +1,28 @@ +Copyright (c) 2007-2009, JSR305 expert group +All rights reserved. + +https://opensource.org/licenses/BSD-3-Clause + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the JSR305 expert group nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-junit.txt b/tools/third-party-licenses/licenses/LICENSE-junit.txt new file mode 100644 index 0000000000..7b5e981e7c --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-junit.txt @@ -0,0 +1,213 @@ +JUnit + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + + a) in the case of the initial Contributor, the initial code and + documentation distributed under this Agreement, and + b) in the case of each subsequent Contributor: + + i) changes to the Program, and + + ii) additions to the Program; + + where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' from a +Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to +the Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) are +not derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly perform, +distribute and sublicense the Contribution of such Contributor, if any, and +such derivative works, in source code and object code form. + + b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under +Licensed Patents to make, use, sell, offer to sell, import and otherwise +transfer the Contribution of such Contributor, if any, in source code and +object code form. This patent license shall apply to the combination of the +Contribution and the Program if, at the time the Contribution is added by the +Contributor, such addition of the Contribution causes such combination to be +covered by the Licensed Patents. The patent license shall not apply to any +other combinations which include the Contribution. No hardware per se is +licensed hereunder. + + c) Recipient understands that although each Contributor grants the +licenses to its Contributions set forth herein, no assurances are provided by +any Contributor that the Program does not infringe the patent or other +intellectual property rights of any other entity. Each Contributor disclaims +any liability to Recipient for claims brought by any other entity based on +infringement of intellectual property rights or otherwise. As a condition to +exercising the rights and licenses granted hereunder, each Recipient hereby +assumes sole responsibility to secure any other intellectual property rights +needed, if any. For example, if a third party patent license is required to +allow Recipient to distribute the Program, it is Recipient's responsibility to +acquire that license before distributing the Program. + + d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright license +set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under +its own license agreement, provided that: + + a) it complies with the terms and conditions of this Agreement; and + + b) its license agreement: + + i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose; + + ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + + iii) states that any provisions which differ from this Agreement are +offered by that Contributor alone and not by any other party; and + + iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable manner on +or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + + a) it must be made available under this Agreement; and + + b) a copy of this Agreement must be included with each copy of the +Program. + +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, if +a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, damages +and costs (collectively "Losses") arising from claims, lawsuits and other legal +actions brought by a third party against the Indemnified Contributor to the +extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may +participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If that +Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such +Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a court +requires any other Contributor to pay any damages as a result, the Commercial +Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each +Recipient is solely responsible for determining the appropriateness of using +and distributing the Program and assumes all risks associated with its exercise +of rights under this Agreement, including but not limited to the risks and +costs of program errors, compliance with applicable laws, damage to or loss of +data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS +GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such +provision valid and enforceable. + +If Recipient institutes patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other software or +hardware) infringes such Recipient's patent(s), then such Recipient's rights +granted under Section 2(b) shall terminate as of the date such litigation is +filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue +and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to time. +No one other than the Agreement Steward has the right to modify this Agreement. +The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial +in any resulting litigation. diff --git a/tools/third-party-licenses/licenses/LICENSE-listenablefuture.txt b/tools/third-party-licenses/licenses/LICENSE-listenablefuture.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-listenablefuture.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-log4j-api.txt b/tools/third-party-licenses/licenses/LICENSE-log4j-api.txt new file mode 100644 index 0000000000..98a324cf06 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-log4j-api.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 1999-2005 The Apache Software Foundation + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-log4j-core.txt b/tools/third-party-licenses/licenses/LICENSE-log4j-core.txt new file mode 100644 index 0000000000..98a324cf06 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-log4j-core.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 1999-2005 The Apache Software Foundation + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-log4j-slf4j-impl.txt b/tools/third-party-licenses/licenses/LICENSE-log4j-slf4j-impl.txt new file mode 100644 index 0000000000..98a324cf06 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-log4j-slf4j-impl.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 1999-2005 The Apache Software Foundation + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-logback-core.txt b/tools/third-party-licenses/licenses/LICENSE-logback-core.txt new file mode 100644 index 0000000000..8953762a3c --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-logback-core.txt @@ -0,0 +1,14 @@ +Logback LICENSE +--------------- + +Logback: the reliable, generic, fast and flexible logging framework. +Copyright (C) 1999-2015, QOS.ch. All rights reserved. + +This program and the accompanying materials are dual-licensed under +either the terms of the Eclipse Public License v1.0 as published by +the Eclipse Foundation + + or (per the licensee's choosing) + +under the terms of the GNU Lesser General Public License version 2.1 +as published by the Free Software Foundation. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-metrics-annotation.txt b/tools/third-party-licenses/licenses/LICENSE-metrics-annotation.txt new file mode 100644 index 0000000000..52823540de --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-metrics-annotation.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2010-2013 Coda Hale and Yammer, Inc., 2014-2020 Dropwizard Team + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-metrics-core.txt b/tools/third-party-licenses/licenses/LICENSE-metrics-core.txt new file mode 100644 index 0000000000..52823540de --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-metrics-core.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2010-2013 Coda Hale and Yammer, Inc., 2014-2020 Dropwizard Team + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-metrics-healthchecks.txt b/tools/third-party-licenses/licenses/LICENSE-metrics-healthchecks.txt new file mode 100644 index 0000000000..52823540de --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-metrics-healthchecks.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2010-2013 Coda Hale and Yammer, Inc., 2014-2020 Dropwizard Team + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-metrics-json.txt b/tools/third-party-licenses/licenses/LICENSE-metrics-json.txt new file mode 100644 index 0000000000..52823540de --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-metrics-json.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2010-2013 Coda Hale and Yammer, Inc., 2014-2020 Dropwizard Team + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-netty-all.txt b/tools/third-party-licenses/licenses/LICENSE-netty-all.txt new file mode 100644 index 0000000000..e25e752cf1 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-netty-all.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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 + + https://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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-netty-tcnative-boringssl-static.txt b/tools/third-party-licenses/licenses/LICENSE-netty-tcnative-boringssl-static.txt new file mode 100644 index 0000000000..e25e752cf1 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-netty-tcnative-boringssl-static.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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 + + https://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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-okhttp.txt b/tools/third-party-licenses/licenses/LICENSE-okhttp.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-okhttp.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-okio.txt b/tools/third-party-licenses/licenses/LICENSE-okio.txt new file mode 100644 index 0000000000..7a4a3ea242 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-okio.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-openmessaging-api.txt b/tools/third-party-licenses/licenses/LICENSE-openmessaging-api.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-openmessaging-api.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-opentelemetry-api-metrics.txt b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-api-metrics.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-api-metrics.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-opentelemetry-api.txt b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-api.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-api.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-opentelemetry-context.txt b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-context.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-context.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-opentelemetry-exporter-prometheus.txt b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-exporter-prometheus.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-exporter-prometheus.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-opentelemetry-exporter-zipkin.txt b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-exporter-zipkin.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-exporter-zipkin.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-opentelemetry-sdk-common.txt b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-sdk-common.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-sdk-common.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-opentelemetry-sdk-metrics.txt b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-sdk-metrics.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-sdk-metrics.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-opentelemetry-sdk-trace.txt b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-sdk-trace.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-sdk-trace.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-opentelemetry-sdk.txt b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-sdk.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-sdk.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-opentelemetry-semconv.txt b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-semconv.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-opentelemetry-semconv.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-rocketmq-acl.txt b/tools/third-party-licenses/licenses/LICENSE-rocketmq-acl.txt new file mode 100644 index 0000000000..f49a4e16e6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-rocketmq-acl.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-rocketmq-broker.txt b/tools/third-party-licenses/licenses/LICENSE-rocketmq-broker.txt new file mode 100644 index 0000000000..f49a4e16e6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-rocketmq-broker.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-rocketmq-client.txt b/tools/third-party-licenses/licenses/LICENSE-rocketmq-client.txt new file mode 100644 index 0000000000..f49a4e16e6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-rocketmq-client.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-rocketmq-common.txt b/tools/third-party-licenses/licenses/LICENSE-rocketmq-common.txt new file mode 100644 index 0000000000..f49a4e16e6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-rocketmq-common.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-rocketmq-filter.txt b/tools/third-party-licenses/licenses/LICENSE-rocketmq-filter.txt new file mode 100644 index 0000000000..f49a4e16e6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-rocketmq-filter.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-rocketmq-logging.txt b/tools/third-party-licenses/licenses/LICENSE-rocketmq-logging.txt new file mode 100644 index 0000000000..f49a4e16e6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-rocketmq-logging.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-rocketmq-namesrv.txt b/tools/third-party-licenses/licenses/LICENSE-rocketmq-namesrv.txt new file mode 100644 index 0000000000..f49a4e16e6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-rocketmq-namesrv.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-rocketmq-remoting.txt b/tools/third-party-licenses/licenses/LICENSE-rocketmq-remoting.txt new file mode 100644 index 0000000000..f49a4e16e6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-rocketmq-remoting.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-rocketmq-srvutil.txt b/tools/third-party-licenses/licenses/LICENSE-rocketmq-srvutil.txt new file mode 100644 index 0000000000..f49a4e16e6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-rocketmq-srvutil.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-rocketmq-store.txt b/tools/third-party-licenses/licenses/LICENSE-rocketmq-store.txt new file mode 100644 index 0000000000..f49a4e16e6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-rocketmq-store.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-rocketmq-test.txt b/tools/third-party-licenses/licenses/LICENSE-rocketmq-test.txt new file mode 100644 index 0000000000..f49a4e16e6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-rocketmq-test.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-rocketmq-tools.txt b/tools/third-party-licenses/licenses/LICENSE-rocketmq-tools.txt new file mode 100644 index 0000000000..f49a4e16e6 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-rocketmq-tools.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-simpleclient.txt b/tools/third-party-licenses/licenses/LICENSE-simpleclient.txt new file mode 100644 index 0000000000..835428fbaa --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-simpleclient.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-simpleclient_common.txt b/tools/third-party-licenses/licenses/LICENSE-simpleclient_common.txt new file mode 100644 index 0000000000..835428fbaa --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-simpleclient_common.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-simpleclient_httpserver.txt b/tools/third-party-licenses/licenses/LICENSE-simpleclient_httpserver.txt new file mode 100644 index 0000000000..835428fbaa --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-simpleclient_httpserver.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-slf4j-api.txt b/tools/third-party-licenses/licenses/LICENSE-slf4j-api.txt new file mode 100644 index 0000000000..744377c437 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-slf4j-api.txt @@ -0,0 +1,21 @@ +Copyright (c) 2004-2017 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/third-party-licenses/licenses/LICENSE-snakeyam.txt b/tools/third-party-licenses/licenses/LICENSE-snakeyam.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-snakeyam.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-system-rules.txt b/tools/third-party-licenses/licenses/LICENSE-system-rules.txt new file mode 100644 index 0000000000..3a4c72849d --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-system-rules.txt @@ -0,0 +1,213 @@ +Common Public License Version 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and + +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' from a +Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to +the Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) are not +derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly perform, +distribute and sublicense the Contribution of such Contributor, if any, and such +derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed +Patents to make, use, sell, offer to sell, import and otherwise transfer the +Contribution of such Contributor, if any, in source code and object code form. +This patent license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, such +addition of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other combinations +which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses +to its Contributions set forth herein, no assurances are provided by any +Contributor that the Program does not infringe the patent or other intellectual +property rights of any other entity. Each Contributor disclaims any liability to +Recipient for claims brought by any other entity based on infringement of +intellectual property rights or otherwise. As a condition to exercising the +rights and licenses granted hereunder, each Recipient hereby assumes sole +responsibility to secure any other intellectual property rights needed, if any. +For example, if a third party patent license is required to allow Recipient to +distribute the Program, it is Recipient's responsibility to acquire that license +before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright license set +forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its +own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title and +non-infringement, and implied warranties or conditions of merchantability and +fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered +by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable manner on or +through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, if +a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, damages +and costs (collectively "Losses") arising from claims, lawsuits and other legal +actions brought by a third party against the Indemnified Contributor to the +extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor to +control, and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may participate in +any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If that +Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such +Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a court +requires any other Contributor to pay any damages as a result, the Commercial +Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each +Recipient is solely responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its exercise of +rights under this Agreement, including but not limited to the risks and costs of +program errors, compliance with applicable laws, damage to or loss of data, +programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS +GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such +provision valid and enforceable. + +If Recipient institutes patent litigation against a Contributor with respect to +a patent applicable to software (including a cross-claim or counterclaim in a +lawsuit), then any patent licenses granted by that Contributor to such Recipient +under this Agreement shall terminate as of the date such litigation is filed. In +addition, if Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the Program +itself (excluding combinations of the Program with other software or hardware) +infringes such Recipient's patent(s), then such Recipient's rights granted under +Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to time. +No one other than the Agreement Steward has the right to modify this Agreement. +IBM is the initial Agreement Steward. IBM may assign the responsibility to serve +as the Agreement Steward to a suitable separate entity. Each new version of the +Agreement will be given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the Agreement +is published, Contributor may elect to distribute the Program (including its +Contributions) under the new version. Except as expressly stated in Sections +2(a) and 2(b) above, Recipient receives no rights or licenses to the +intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial in +any resulting litigation. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-truth.txt b/tools/third-party-licenses/licenses/LICENSE-truth.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-truth.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-zipkin-reporter.txt b/tools/third-party-licenses/licenses/LICENSE-zipkin-reporter.txt new file mode 100644 index 0000000000..9c8f3ea087 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-zipkin-reporter.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed 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. \ No newline at end of file diff --git a/tools/third-party-licenses/licenses/LICENSE-zipkin-sender-okhttp3.txt b/tools/third-party-licenses/licenses/LICENSE-zipkin-sender-okhttp3.txt new file mode 100644 index 0000000000..8dada3edaf --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-zipkin-sender-okhttp3.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed 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. diff --git a/tools/third-party-licenses/licenses/LICENSE-zipkin.txt b/tools/third-party-licenses/licenses/LICENSE-zipkin.txt new file mode 100644 index 0000000000..0c1111bc79 --- /dev/null +++ b/tools/third-party-licenses/licenses/LICENSE-zipkin.txt @@ -0,0 +1,216 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed 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. + +This product contains a modified part of Gson, distributed by Google: + + * License: Apache License v2.0 + * Homepage: https://github.com/google/gson + +This product contains a modified part of Guava, distributed by Google: + + * License: Apache License v2.0 + * Homepage: https://github.com/google/guava + +This product contains a modified part of Okio, distributed by Square: + + * License: Apache License v2.0 + * Homepage: https://github.com/square/okio