diff --git a/.asf.yaml b/.asf.yaml new file mode 100644 index 0000000000..24bcbcda98 --- /dev/null +++ b/.asf.yaml @@ -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. +# + +github: + description: EventMesh is a dynamic cloud-native eventing infrastruture 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. + homepage: https://eventmesh.apache.org/ + labels: + - event-mesh + - event-gateway + - event-driven + - event-streaming + - event-sourcing + - event-governance + - event-routing + - cloud-native + - serverless + - serverless-workflow + - esb + - message-bus + - cqrs + enabled_merge_buttons: + squash: true + merge: false + rebase: false + protected_branches: + master: + required_status_checks: + strict: true + required_pull_request_reviews: + dismiss_stale_reviews: true + required_approving_review_count: 2 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..381e4d77e6 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1 @@ +#TBD \ No newline at end of file diff --git a/.github/workflows/gitee-mirror.yml b/.github/workflows/gitee-mirror.yml index 6582dfd5ac..b29e0806f6 100644 --- a/.github/workflows/gitee-mirror.yml +++ b/.github/workflows/gitee-mirror.yml @@ -21,25 +21,25 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - - name: Mirror the Github organization repos to Gitee. - uses: Yikun/hub-mirror-action@master - with: - src: github/WeBankFinTech - dst: gitee/webank - # 这里请填写与gitee上公钥匹配的的 ssh private key,参见:https://gitee.com/profile/sshkeys - # 填写地址:https://github.com/WeBankFinTech/fes.js/settings/secrets - dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} - # 这里请填写 gitee的令牌,参见:https://gitee.com/profile/personal_access_tokens - # 填写地址:https://github.com/WeBankFinTech/fes.js/settings/secrets - dst_token: ${{ secrets.GITEE_TOKEN }} - # 项目同步白名单,可以选择填写多个,以英文逗号分割 - static_list: "EventMesh" - # 是否强制同步 - force_update: true - # 账号类型:对 luban-h5 而言是 user,因为是个人项目;如果是企业项目,请填写 org,因为是组织下的项目 - account_type: org - clone_style: ssh - + - name: Mirror the Github organization repos to Gitee. + uses: Yikun/hub-mirror-action@master + with: + src: github/WeBankFinTech + dst: gitee/webank + # 这里请填写与gitee上公钥匹配的的 ssh private key,参见:https://gitee.com/profile/sshkeys + # 填写地址:https://github.com/WeBankFinTech/fes.js/settings/secrets + dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} + # 这里请填写 gitee的令牌,参见:https://gitee.com/profile/personal_access_tokens + # 填写地址:https://github.com/WeBankFinTech/fes.js/settings/secrets + dst_token: ${{ secrets.GITEE_TOKEN }} + # 项目同步白名单,可以选择填写多个,以英文逗号分割 + static_list: "EventMesh" + # 是否强制同步 + force_update: true + # 账号类型:对 luban-h5 而言是 user,因为是个人项目;如果是企业项目,请填写 org,因为是组织下的项目 + account_type: org + clone_style: ssh + build-and-deploy: runs-on: ubuntu-latest steps: @@ -56,5 +56,5 @@ jobs: uses: JamesIves/github-pages-deploy-action@3.7.1 with: GITHUB_TOKEN: ${{ secrets.EVENTMESH }} - BRANCH: gh-pages + BRANCH: gh-pages FOLDER: docs/.vuepress/dist # The folder the action should deploy. diff --git a/.travis.yml b/.travis.yml index 4c2ba8ba57..a6b1867585 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,14 @@ dist: trusty language: java jdk: -- oraclejdk8 + - oraclejdk8 script: -- travis_retry gradle check + - travis_retry ./gradlew clean build -after_success: -- gradle clean test jacocoAllTestReport coveralls +#after_success: +# - ./gradlew clean env: global: - - secure: "T1QAuaAzcB7K8YjAAVVb4P9+W0JAdOFbyBwRxliyyoSZUShlIqa0eE7ioXHXWBP/d5f3XtROse6lq2qILqcU9sFSncKE2vRJlwJ5p7R23WIsCXdV70A9AVE2gLJcIJiOTMwd/YYYzNDrGLp3CSJNcKo8t7t70V2j/11I9xPTOHnaZ8FHGC3d/7bjfR/+g/3d4EOCvV8Vm6ndEmmailmF8OJ/kcbuRbArKIehjUwNDyQZfwAc9+vvPZlHgnQvR1pJ/KiK6muEIi7RQohDq7lMTmcc2LZSYgy/+aqFrmBcQwXScABFmSwysQ4KMXfrCqqMsBdmvno/NoKVGofHHKdym/oauv/G3lxLx5sgM9A7ZSFBK08x08r7u/6TDsTFmQ9LzVFDNo/OLZhxs3dr9x2C9Pa2A7IP1i1oVbbYkwBJv4z6o3khWpQAAY/IWijlCZ9vkjFfqdIXbvlPqamEaFRAmK5I3MVqL2+eBF+2Or/zwv4rXjo+v5LUKTfmDl77QUshPv6J+hblbBR0cJ/ZTSh9rHgdqhEzPGSt3e0YrEefkKWfinBr8TjIsHgQgmfU8Kz7gf7tvioOuAgKj4WlgEQJs3dPp7J5zxFVNMM6teAMFy8c2MtAdzKrs13Ri1qZWtL6B7JWlH6yhHqhKghyJhRjUFNVZnBkA/z9gzDKZ+tz2m8=" \ No newline at end of file + - secure: "T1QAuaAzcB7K8YjAAVVb4P9+W0JAdOFbyBwRxliyyoSZUShlIqa0eE7ioXHXWBP/d5f3XtROse6lq2qILqcU9sFSncKE2vRJlwJ5p7R23WIsCXdV70A9AVE2gLJcIJiOTMwd/YYYzNDrGLp3CSJNcKo8t7t70V2j/11I9xPTOHnaZ8FHGC3d/7bjfR/+g/3d4EOCvV8Vm6ndEmmailmF8OJ/kcbuRbArKIehjUwNDyQZfwAc9+vvPZlHgnQvR1pJ/KiK6muEIi7RQohDq7lMTmcc2LZSYgy/+aqFrmBcQwXScABFmSwysQ4KMXfrCqqMsBdmvno/NoKVGofHHKdym/oauv/G3lxLx5sgM9A7ZSFBK08x08r7u/6TDsTFmQ9LzVFDNo/OLZhxs3dr9x2C9Pa2A7IP1i1oVbbYkwBJv4z6o3khWpQAAY/IWijlCZ9vkjFfqdIXbvlPqamEaFRAmK5I3MVqL2+eBF+2Or/zwv4rXjo+v5LUKTfmDl77QUshPv6J+hblbBR0cJ/ZTSh9rHgdqhEzPGSt3e0YrEefkKWfinBr8TjIsHgQgmfU8Kz7gf7tvioOuAgKj4WlgEQJs3dPp7J5zxFVNMM6teAMFy8c2MtAdzKrs13Ri1qZWtL6B7JWlH6yhHqhKghyJhRjUFNVZnBkA/z9gzDKZ+tz2m8=" \ No newline at end of file diff --git a/CNAME b/CNAME deleted file mode 100644 index 8feffb14d1..0000000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -www.eventmesher.com diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index de1080bc63..68c870c4b2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Contributing to EventMesh -Welcome to EventMesh! This document is a guideline about how to contribute to EventMesh. -If you find something incorrect or missing, please leave comments / suggestions. +Welcome to EventMesh! This document is a guideline about how to contribute to EventMesh. If you find something incorrect +or missing, please leave comments / suggestions. ## Before you get started @@ -11,11 +11,11 @@ You should have JDK installed in your operating system. ## Contributing -We are always very happy to have contributions, whether for typo fix, bug fix or big new features. -Please do not ever hesitate to ask a question or send a pull request. +We are always very happy to have contributions, whether for typo fix, bug fix or big new features. Please do not ever +hesitate to ask a question or send a pull request. -We strongly value documentation and integration with other projects. -We are very glad to accept improvements for these aspects. +We strongly value documentation and integration with other projects. We are very glad to accept improvements for these +aspects. ### GitHub workflow @@ -31,29 +31,29 @@ Here are the workflow for contributors: 6. Push your commits to your forked repository 7. Create a pull request -Please follow [the pull request template](./.github/PULL_REQUEST_TEMPLATE.md). -Please make sure the PR has a corresponding issue. [GitHub Issues](https://github.com/WeBankFinTech/EventMesh/issues) +Please follow [the pull request template](./.github/PULL_REQUEST_TEMPLATE.md). Please make sure the PR has a +corresponding issue. [GitHub Issues](https://github.com/apache/incubator-eventmesh/issues) -After creating a PR, one or more reviewers will be assigned to the pull request. -The reviewers will review the code. +After creating a PR, one or more reviewers will be assigned to the pull request. The reviewers will review the code. -Before merging a PR, squash any fix review feedback, typo, merged, and rebased sorts of commits. -The final commit message should be clear and concise. +Before merging a PR, squash any fix review feedback, typo, merged, and rebased sorts of commits. The final commit +message should be clear and concise. ### Open an issue / PR -We use [GitHub Issues](https://github.com/WeBankFinTech/EventMesh/issues) and [Pull Requests](https://github.com/WeBankFinTech/EventMesh/pulls) for trackers. +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 can [open an issue on GitHub](https://github.com/WeBankFinTech/EventMesh/issues/new) to report it. -Please follow the guideline message in the issue template. +If you find a typo in a document, 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 design and usage. +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 +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 changes -to a few individual PRs. +Note that 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 diff --git a/CONTRIBUTING.zh-CN.md b/CONTRIBUTING.zh-CN.md index 8c63718e65..742ccbdc32 100644 --- a/CONTRIBUTING.zh-CN.md +++ b/CONTRIBUTING.zh-CN.md @@ -1,7 +1,6 @@ # 贡献给EventMesh -欢迎使用EventMesh! 本文档是有关如何为EventMesh做出贡献的指南。 -如果发现不正确或缺失的内容,请留下评论/建议。 +欢迎使用EventMesh! 本文档是有关如何为EventMesh做出贡献的指南。 如果发现不正确或缺失的内容,请留下评论/建议。 ## 开始之前 @@ -11,11 +10,9 @@ ## 贡献 -无论是对于拼写错误,BUG修复还是重要的新功能,我们总是很乐意为您做出贡献。 -请不要犹豫,提出问题或发送请求请求。 +无论是对于拼写错误,BUG修复还是重要的新功能,我们总是很乐意为您做出贡献。 请不要犹豫,提出问题或发送请求请求。 -我们非常重视文档以及与其他项目的集成。 -我们很高兴接受这些方面的改进。 +我们非常重视文档以及与其他项目的集成。 我们很高兴接受这些方面的改进。 ### GitHub工作流程 @@ -23,39 +20,33 @@ 这是贡献者的工作流程 : -1. Fork到您个人仓库 -2. 克隆到本地存储库 -3. 创建一个新分支并对其进行处理 -4. 保持分支同步 +1. Fork到您个人仓库 +2. 克隆到本地存储库 +3. 创建一个新分支并对其进行处理 +4. 保持分支同步 5. 提交您的更改(确保您的提交消息简明扼要) 6. 将您的提交推送到分叉的存储库 7. 创建PR合并请求 请遵循[Pull Requests模板](./.github/PULL_REQUEST_TEMPLATE.md). -请确保PR对应有相应的问题. [GitHub Issues](https://github.com/WeBankFinTech/EventMesh/issues) +请确保PR对应有相应的问题. [GitHub Issues](https://github.com/apache/incubator-eventmesh/issues) -创建PR后,将为拉取请求分配一个或多个审阅者。 -审阅者将审阅代码。 +创建PR后,将为拉取请求分配一个或多个审阅者。 审阅者将审阅代码。 -在合并PR之前,请压缩所有修订审阅反馈,拼写错误,合并的内容和基于基础的提交内容。 -最终的提交消息应该清晰简洁。 +在合并PR之前,请压缩所有修订审阅反馈,拼写错误,合并的内容和基于基础的提交内容。 最终的提交消息应该清晰简洁。 ### 打开问题/ PR -我们将使用Issues和Pull Requests作为跟踪器 -[GitHub Issues](https://github.com/WeBankFinTech/EventMesh/issues) -[Pull Requests](https://github.com/WeBankFinTech/EventMesh/pulls) +我们将使用Issues和Pull Requests作为跟踪器 +[GitHub Issues](https://github.com/apache/incubator-eventmesh/issues) +[Pull Requests](https://github.com/apache/incubator-eventmesh/pulls) -如果您在文档中发现拼写错误,在代码中发现错误,想要新功能或提出建议, -您可以提出问题[在GitHub上打开问题](https://github.com/WeBankFinTech/EventMesh/issues/new) +如果您在文档中发现拼写错误,在代码中发现错误,想要新功能或提出建议, 您可以提出问题[在GitHub上打开问题](https://github.com/apache/incubator-eventmesh/issues/new) 请按照问题模板中的准则消息进行操作。 -如果您想贡献,请遵循[贡献工作流程](#github-workflow)并创建一个新的拉取请求。 -如果您的PR包含较大的更改,例如组件重构或新组件,请写详细文档 -有关其设计和使用的信息。 +如果您想贡献,请遵循[贡献工作流程](#github-workflow)并创建一个新的拉取请求。 如果您的PR包含较大的更改,例如组件重构或新组件,请写详细文档 有关其设计和使用的信息。 -请注意,单个拉取请求不应太大。如果需要进行重大更改,最好将更改分开 -到一些个人PR。 +请注意,单个拉取请求不应太大。如果需要进行重大更改,最好将更改分开 到一些个人PR。 ### 代码审查 diff --git a/DISCLAIMER-WIP b/DISCLAIMER-WIP new file mode 100644 index 0000000000..e72dd1b9d0 --- /dev/null +++ b/DISCLAIMER-WIP @@ -0,0 +1,19 @@ +Apache EventMesh is an effort undergoing incubation at The Apache Software Foundation (ASF), +sponsored by the Apache Incubator PMC. + +Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, +communications, and decision-making process have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or stability of the code, +it does indicate that the project has yet to be fully endorsed by the ASF. + +Some of the incubating project’s releases may not be fully compliant with ASF policy. +For example, releases may have incomplete or un-reviewed licensing conditions. +What follows is a list of issues the project is currently aware of (this list is likely to be incomplete): + +1- Releases may have incomplete licensing conditions + + +If you are planning to incorporate this work into your product/project, +please be aware that you will need to conduct a thorough licensing review to determine the overall implications of including this work. +For the current status of this project through the Apache Incubator, visit: https://incubator.apache.org/projects/eventmesh.html diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000000..19d0bec195 --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +Apache EventMesh (incubating) +Copyright 2021 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/README.md b/README.md index ee0d26be5d..690f43b7ec 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ -[![Build Status](https://www.travis-ci.org/WeBankFinTech/DeFiBus.svg?branch=master)](https://www.travis-ci.org/WeBankFinTech/EventMesh) -[![Coverage Status](https://coveralls.io/repos/github/WeBankFinTech/DeFiBus/badge.svg?branch=master)](https://coveralls.io/github/WeBankFinTech/EventMesh?branch=master) -[![GitHub release](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/WeBankFinTech/EventMesh/releases) +# Apache EventMesh (Incubating) +[![Build Status](https://www.travis-ci.org/apache/incubator-eventmesh.svg?branch=develop)](https://www.travis-ci.org/github/apache/incubator-eventmesh.svg?branch=develop) +[![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) ## What is EventMesh? -EventMesh is a dynamic cloud-native eventing infrastruture 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. +EventMesh(incubating) is a dynamic cloud-native eventing infrastruture 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 Ecosystem:** @@ -20,15 +22,6 @@ EventMesh is a dynamic cloud-native eventing infrastruture used to decouple the ![architecture2](docs/images/eventmesh-panels.png) -The EventMesh allows events from one application to be dynamically routed to any other application. -General functions of the eventmesh: - -* Event driven; -* Event governance; -* Dynamic routing; -* Cloud native; -* Flow control; -* Load balance **Support connecting event store:** @@ -51,33 +44,30 @@ The protocol of eventmesh is easier and convenient, you can read more [here](doc | v1.1.0 |Support RocketMQ as eventstore| | v1.1.1 |Support https| | v1.2.0 |Support OpenMessaging API,support Plug-in architecture, support http sub, support cloud native deploy| -| V1.3.0 |Support CloudEvents protocol,support OpenMessaging Connector| +| V1.3.0 |Support CloudEvents, Event Streaming| +| |Support Event function,triggers and bindings| +| |Support Event orchestration, Servelss workflow| | |Support Event transaction| -| |Support Event filter| -| |Support Promethus as metrics| +| |Support Event schema| +| |Support Event governance, dashboard| +| |Support Event security| | |Support multi language SDK(c\go\python\wasm)| -| |Support Event orchestration| -| |Support Event governance| +| |Support Promethus as metrics| | |Support Skywalking as tracing| -| |Support Spiffe as security| -| |Support Event replay| -| |Support openmessaging-storage-dledger as default event store| -| |Support Dashboard| -| |Support schema registry| -| |Support gRPC protocol| -| |Support MQTT protocol| -| |Support routing functions with triggers and bindings| +| |Support streaming event store| +| |Support gRPC protocol| +| |Support MQTT protocol| ## Quick Start -1. Build and deploy event-store(RocketMQ), see [instruction](https://rocketmq.apache.org/docs/quick-start/). +1. Build and deploy event-store(default RocketMQ), see [instruction](https://rocketmq.apache.org/docs/quick-start/). 2. Build and deploy eventmesh-runtime, see instruction ['eventmesh-runtime quickstart'](docs/en/instructions/eventmesh-runtime-quickstart.md). -3. Run eventmesh-sdk-java demo, see instruction ['eventmesh-sdk-java quickstart'](docs/en/instructions/eventmesh-sdk-java-quickstart.md). +3. Run eventmesh-sdk-java demo, see instruction ['eventmesh-sdk-java quickstart'](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/WeBankFinTech/EventMesh/issues) +You can start with the issues labeled with good first issue. +[GitHub Issues](https://github.com/apache/incubator-eventmesh/issues) ## License [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation. @@ -88,6 +78,7 @@ WeChat group: ![wechat_qr](docs/images/mesh-helper.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)| diff --git a/README.zh-CN.md b/README.zh-CN.md index 6604ae83fa..0fc9ac7508 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,10 +1,14 @@ -[![Build Status](https://www.travis-ci.org/WeBankFinTech/DeFiBus.svg?branch=master)](https://www.travis-ci.org/WeBankFinTech/EventMesh) -[![Coverage Status](https://coveralls.io/repos/github/WeBankFinTech/DeFiBus/badge.svg?branch=master)](https://coveralls.io/github/WeBankFinTech/EventMesh?branch=master) -[![GitHub release](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/WeBankFinTech/EventMesh/releases) +# Apache EventMesh (Incubating) +[![Build Status](https://www.travis-ci.org/apache/incubator-eventmesh.svg?branch=develop)](https://www.travis-ci.org/github/apache/incubator-eventmesh.svg?branch=develop) +[![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) ## 什么是Event Mesh? EventMesh是一个动态的云原生事件驱动架构基础设施,用于分离应用程序和后端中间件层,它支持广泛的用例,包括复杂的混合云、使用了不同技术栈的分布式架构。 + +![architecture1](docs/images/eventmesh-multi-runtime.png) + +**EventMesh生态:** ![architecture1](docs/images/eventmesh-define.png) **EventMesh架构:** @@ -15,15 +19,6 @@ EventMesh是一个动态的云原生事件驱动架构基础设施,用于分 ![architecture2](docs/images/eventmesh-panels.png) -Event Mesh允许将来自一个应用程序的事件动态路由到任何其他应用程序. -Event Mesh的一般功能: -* 事件驱动; -* 事件治理; -* 动态路由; -* 云原生; -* 流控; -* 负载均衡 - **支持连接的事件存储:** * [RocketMQ](https://github.com/apache/rocketmq):RocketMQ是一个分布式消息流平台,具有低延迟、高性能和可靠性、万亿级容量和灵活的可伸缩性。 @@ -39,28 +34,25 @@ Event Mesh的一般功能: eventmesh的通信协议更加简洁方便,详细内容,阅读更多[这里](docs/cn/instructions/eventmesh-runtime-protocol.zh-CN.md) ## RoadMap -| version | feature | -| ------- | ------------------------------------------------------------ | -| v1.0.0 | Support java-sdk , tcp pub/sub, http pub | -| v1.1.0 | Support RocketMQ as eventstore | -| v1.1.1 | Support https | -| v1.2.0 | Support Plug-in architecture, support http sub, support cloud native deploy | -| V1.3.0 | Support CloudEvents protocol | -| | Support Event transaction | -| | Support Event filter | -| | Support Promethus as metrics | -| | Support multi language SDK(c\go\python\wasm) | -| | Support Event orchestration | -| | Support Event governance | -| | Support Skywalking as tracing | -| | Support Spiffe as security | -| | Support Event replay | -| | Support openmessaging-storage-dledger as default event store | -| | Support Dashboard | -| | Support schema registry | -| | Support gRPC protocol | -| | Support MQTT protocol | -| | Support routing functions with triggers and bindings | +| version | feature | +| ---- | ---- | +| v1.0.0 |Support java-sdk , tcp pub/sub, http pub| +| v1.1.0 |Support RocketMQ as eventstore| +| v1.1.1 |Support https| +| v1.2.0 |Support OpenMessaging API,support Plug-in architecture, support http sub, support cloud native deploy| +| V1.3.0 |Support CloudEvents, Event Streaming| +| |Support Event function,triggers and bindings| +| |Support Event orchestration, Servelss workflow| +| |Support Event transaction| +| |Support Event schema| +| |Support Event governance, dashboard| +| |Support Event security| +| |Support multi language SDK(c\go\python\wasm)| +| |Support Promethus as metrics| +| |Support Skywalking as tracing| +| |Support streaming event store| +| |Support gRPC protocol| +| |Support MQTT protocol| ## 快速开始 1. 构建并部署event-store(RocketMQ), 请参见[说明](https://rocketmq.apache.org/docs/quick-start/) @@ -70,13 +62,21 @@ eventmesh的通信协议更加简洁方便,详细内容,阅读更多[这里] ## 贡献 永远欢迎参与共建, 请参阅[贡献](CONTRIBUTING.zh-CN.md)了解详细指南 -您可以从问题开始. -[GitHub Issues](https://github.com/WeBankFinTech/EventMesh/issues) +您可以从问题开始. +[GitHub Issues](https://github.com/apache/incubator-eventmesh/issues) ## License [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation -## 联系人 +## 开发社区 微信群: ![wechat_qr](docs/images/mesh-helper.png) + +Mailing Lists: + +| 列表名称 | 描述 |订阅 |取消订阅|邮件列表存档 +| ---- | ---- |---- | ---- | ---- | +|Users |用户支持与用户问题| [点击订阅](mailto:users-subscribe@eventmesh.incubator.apache.org) |[点击取消订阅](mailto:users-unsubscribe@eventmesh.incubator.apache.org) |[邮件列表存档](https://lists.apache.org/list.html?users@eventmesh.apache.org)| +|Development |开发相关| [点击订阅](mailto:dev-subscribe@eventmesh.incubator.apache.org) |[点击取消订阅](mailto:dev-unsubscribe@eventmesh.incubator.apache.org) |[邮件列表存档](https://lists.apache.org/list.html?dev@eventmesh.apache.org)| +|Commits |所有与仓库相关的commits信息通知| [点击订阅](mailto:commits-subscribe@eventmesh.incubator.apache.org) |[点击取消订阅](mailto:commits-unsubscribe@eventmesh.incubator.apache.org) |[邮件列表存档](https://lists.apache.org/list.html?commits@eventmesh.apache.org)| diff --git a/_config.yml b/_config.yml deleted file mode 100644 index c4192631f2..0000000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-cayman \ No newline at end of file diff --git a/build.gradle b/build.gradle index 6019236e5b..e461728bd3 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,8 @@ import java.util.concurrent.TimeUnit +//import com.github.spotbugs.snom.SpotBugsTask + buildscript { repositories { maven { @@ -30,15 +32,36 @@ buildscript { } dependencies { - //classpath("net.sourceforge.pmd:pmd-java:5.4.1") - //classpath("com.puppycrawl.tools:checkstyle:6.16.1") - classpath("gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.0.7") - classpath('com.github.spotbugs:spotbugs:4.0.0') + classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.1" } } allprojects { apply plugin: 'java' + apply plugin: "eclipse" + apply plugin: "idea" + apply plugin: "project-reports" + apply plugin: "maven-publish" + apply plugin: "com.github.spotbugs" + apply plugin: "project-reports" + apply plugin: "jacoco" + apply plugin: "pmd" + apply plugin: "java-library" + apply plugin: 'signing' + +// print(project) +// if (project.findProperty("jdk") == "1.7") { +// sourceCompatibility = 1.7 +// targetCompatibility = 1.7 +// version = version + "-jdk7" +// } else { +// sourceCompatibility = 1.8 +// targetCompatibility = 1.8 +// version = version + "-jdk8" +// } + [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8' + + compileJava.options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" clean.doFirst { @@ -47,49 +70,119 @@ allprojects { delete 'out' } - if (project.findProperty("snapshot") instanceof String) { - if (project.property("snapshot").toBoolean()) - version = version + "-SNAPSHOT" + if ((project.findProperty("snapshot") instanceof String) && (Boolean.valueOf(project.property("snapshot")))) { + version = version + "-SNAPSHOT" } + } task tar(type: Tar) { - archiveExtension = 'tar.gz' + extension = 'tar.gz' compression = Compression.GZIP - archiveFileName = project.name + '_' + project.version + '.' + archiveExtension + archiveFileName = project.name + '_' + project.version + '.' + extension destinationDirectory = new File(projectDir, 'build') into('/') { from 'dist' } } + task zip(type: Zip) { - archiveExtension = 'zip' - archiveFileName = project.name + '.' + project.version + '.' + archiveExtension + extension = 'zip' + archiveFileName = project.name + '.' + project.version + '.' + extension destinationDirectory = new File(projectDir, 'build') into('/') { from 'dist' } } + subprojects { + List fastjson = [ + "com.alibaba:fastjson:1.2.71" + ] - apply plugin: "maven" - apply plugin: "eclipse" - apply plugin: "idea" - apply plugin: "project-reports" - apply plugin: "jacoco" -// apply plugin: "checkstyle" - apply plugin: "pmd" - apply plugin: 'com.github.spotbugs' + List jackson = [ + 'com.fasterxml.jackson.core:jackson-databind:2.11.0', + 'com.fasterxml.jackson.core:jackson-core:2.11.0', + 'com.fasterxml.jackson.core:jackson-annotations:2.11.0' + ] - [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8' + List apache_commons = [ + "org.apache.commons:commons-lang3:3.6", + "org.apache.commons:commons-collections4:4.1" + ] - compileJava.options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" + List httpclient = [ + "org.apache.httpcomponents:httpclient:4.5.2" + ] + + List guava = [ + "com.google.guava:guava:29.0-jre" + ] + + List netty = [ + "io.netty:netty-all:4.1.49.Final" + ] + + List junit = [ + "junit:junit:4.12" + ] + + List log = [ + "org.slf4j:slf4j-api:1.7.30" + ] + + List log4j2 = [ + "org.apache.logging.log4j:log4j-api:2.13.3", + "org.apache.logging.log4j:log4j-core:2.13.3", + "org.apache.logging.log4j:log4j-slf4j-impl:2.13.3", + "org.apache.logging.log4j:log4j-web:2.13.3", + "com.lmax:disruptor:3.4.2" + ] + + + List common = [ + "commons-io:commons-io:2.4", + "org.apache.commons:commons-text:1.9" + ] + + List assertj = [ + "org.assertj:assertj-core:2.6.0" + ] + + List mock = [ + "org.mockito:mockito-core:2.23.0", + "org.powermock:powermock-module-junit4:2.0.2", + "org.powermock:powermock-api-mockito2:2.0.2", + ] + + dependencies { + implementation apache_commons, guava, log, log4j2, fastjson, jackson, common, httpclient, netty + testImplementation apache_commons, guava, log, log4j2, fastjson, jackson, common, junit, assertj, mock, httpclient, netty + spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0' + spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.7' + } + + + sourceSets { + main { + java.srcDirs = ['src/main/java'] + } + + test { + java.srcDirs = ['src/test/java'] + } + } + + clean.doFirst { + delete 'build' + delete 'dist' + } jacoco { - toolVersion = "0.8.5" + toolVersion = "0.8.6" reportsDir = file("$buildDir/reports/jacoco") } @@ -100,7 +193,7 @@ subprojects { reports { xml.enabled false csv.enabled false - html.destination file("${buildDir}/reports/jacoco") + html.destination file("${buildDir}/reports/jacoco/html") } } @@ -119,98 +212,93 @@ subprojects { // } // } +// sourceSets { +// main { +// java { +// srcDir 'src/main/java' +// } +// +// resources { +// srcDir 'src/main/resources' +// } +// +// } +// +// test { +// java { +// srcDir 'src/test/java' +// } +// +// resources { +// srcDir 'src/test/resources' +// } +// +// } +// +// +// } + + spotbugs { - toolVersion = '4.0.2' + //toolVersion = '4.2.3' ignoreFailures = true - effort = "default" - reportLevel = "default" showProgress = true + showStackTraces = true + //reportLevel = 'default' + effort = 'default' + //visitors = [ 'FindSqlInjection', 'SwitchFallthrough' ] + //omitVisitors = [ 'FindNonShortCircuit' ] + reportsDir = file("$buildDir/reports/spotbugs") + //includeFilter = file('spotbugs-include.xml') + //excludeFilter = file('spotbugs-exclude.xml') + //onlyAnalyze = ['org/apache/eventmesh/**'] + projectName = rootProject.name + release = version + extraArgs = ['-nested:false'] + //jvmArgs = [ '-Duser.language=zh' ] + maxHeapSize = '256m' + } -// tasks.withType(com.github.spotbugs.SpotBugsTask) { -// sourceDirs = [sourceSets.main] -// reports { -// xml.enabled = false -// html.enabled = true -// } -// } spotbugsMain { + reports { xml.enabled = false - html.enabled = true + html { + enabled = true + destination = file("$buildDir/reports/spotbugs/main/spotbugs.html") + stylesheet = 'fancy-hist.xsl' + } } } spotbugsTest { reports { xml.enabled = false - html.enabled = true + html { + enabled = true + destination = file("$buildDir/reports/spotbugs/test/spotbugs.html") + stylesheet = 'fancy-hist.xsl' + } } } - tasks.withType(Pmd) { - reports { - xml.enabled = false - html.enabled = true - } - } +// tasks.withType(Pmd) { +// reports { +// xml.enabled = false +// html.enabled = true +// } +// } pmd { consoleOutput = true toolVersion = "6.23.0" - rulePriority = 5 + rulesMinimumPriority = 5 ruleSets = ["category/java/errorprone.xml", "category/java/bestpractices.xml"] ignoreFailures = true } - - - List junit = [ - "junit:junit:4.12" - ] - - List apache_commons = [ - "org.apache.commons:commons-collections4:4.1", - "commons-beanutils:commons-beanutils:1.9.3", - "org.apache.commons:commons-lang3:3.6", - "commons-codec:commons-codec:1.10" - - ] - - List log = [ - "org.slf4j:slf4j-api:1.7.30" - ] - - List guava = [ - "com.google.guava:guava:29.0-jre" - ] - - List fastjson = [ - "com.alibaba:fastjson:1.2.71" - ] - - List common_io = [ - "commons-io:commons-io:2.4" - ] - - List assertj = [ - "org.assertj:assertj-core:2.6.0" - ] - - List mock = [ -// "org.mockito:mockito-core:1.10.19", -"org.mockito:mockito-core:2.23.0", -"org.powermock:powermock-module-junit4:2.0.2", -"org.powermock:powermock-api-mockito2:2.0.2", - ] - - dependencies { - compile apache_commons, guava, log, fastjson, common_io - testCompile apache_commons, guava, log, fastjson, common_io, junit, assertj, mock - runtime apache_commons, guava, log, fastjson, common_io - } - jar { manifest { attributes("Specification-Version": project.version, @@ -244,7 +332,7 @@ subprojects { } copy { into '../dist/lib' - from project.configurations.runtime + from project.configurations.runtimeClasspath exclude '**/*.properties*' exclude '**/*testng*.jar' exclude '**/*powermock*.jar' @@ -274,7 +362,7 @@ subprojects { javadoc { source = sourceSets.main.java - classpath = configurations.compile + //classpath = configurations.implementation destinationDir = reporting.file("javadoc") } @@ -294,15 +382,82 @@ subprojects { archives packageSources } + if (!Boolean.valueOf(signEnabled)) { + tasks.whenTaskAdded {task -> + if(task.name.contains("sign")) { + task.enabled = false + } + } + } + repositories { maven { url "https://maven.aliyun.com/repository/public" } mavenCentral() + mavenLocal() } + configurations.all { resolutionStrategy.cacheChangingModulesFor 0, TimeUnit.SECONDS resolutionStrategy.cacheDynamicVersionsFor 0, TimeUnit.SECONDS } + publishing { + publications { + mavenJava(MavenPublication) { + from components.java + artifact packageSources + artifact packageJavadoc + versionMapping { + usage('java-api') { + fromResolutionOf('runtimeClasspath') + } + usage('java-runtime') { + fromResolutionResult() + } + } + pom { + name = 'EventMesh' + description = 'Apache EventMesh' + url = 'https://github.com/apache/incubator-eventmesh' + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id = 'Apache EventMesh(incubating)' + name = 'Apache EventMesh(incubating) of ASF' + url = 'https://eventmesh.apache.org/' + } + } + scm { + connection = 'scm:git:git@github.com:apache/incubator-eventmesh.git' + developerConnection = 'scm:git:git@github.com:apache/incubator-eventmesh.git' + url = 'https://github.com/apache/incubator-eventmesh' + } + } + } + } + repositories { + maven { + def releasesRepoUrl = 'https://repository.apache.org/content/repositories/releases/' + def snapshotsRepoUrl = 'https://repository.apache.org/content/repositories/snapshots/' + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + credentials { + username apacheUserName + password apachePassWord + } + + } + } + } + + signing { + sign publishing.publications.mavenJava + } + } diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 76c3bc6a09..1f6bad1330 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -1,74 +1,74 @@ module.exports = { - title: 'EventMesh', - description: 'EventMesh', - head: [ - ['link', { rel: 'icon', href: '/logo.png' }] - ], - locales: { - '/': { - lang: 'English', - title: 'EventMesh', - description: '' - }, - '/cn/': { - lang: '中文', - title: 'EventMesh', - description: '' - }, - }, - themeConfig: { + title: 'EventMesh', + description: 'EventMesh', + head: [ + ['link', {rel: 'icon', href: '/logo.png'}] + ], locales: { - '/': { - selectText: 'Languages', - label: 'English', - ariaLabel: 'Languages', - nav: [ - { text: 'Community', link: '/en/community/' }, - { - text: 'Blog', - link: '/en/blog/' - }, - { - text: 'Documentation', link: '/en/documentation/' - }, - { text: 'Github', link: 'https://github.com/WeBankFinTech/EventMesh'}, - ], - }, - '/en/': { - selectText: 'Languages', - label: 'English', - ariaLabel: 'Languages', - nav: [ - { text: 'Community', link: '/en/community/' }, - { - text: 'Blog', - link: '/en/blog/' - }, - { - text: 'Documentation', link: '/en/documentation/' - }, - { text: 'Github', link: 'https://github.com/WeBankFinTech/EventMesh'}, - ], - }, - '/cn/': { - // 多语言下拉菜单的标题 - selectText: '选择语言', - // 该语言在下拉菜单中的标签 - label: '简体中文', - nav: [ - { text: '社区', link: '/cn/community/' }, - { - text: '博客', - link: '/cn/blog/' - }, - { - text: '文档', link: '/en/documentation/' - }, - { text: 'Github', link: 'https://github.com/WeBankFinTech/EventMesh'}, - ], - } + '/': { + lang: 'English', + title: 'EventMesh', + description: '' + }, + '/cn/': { + lang: '中文', + title: 'EventMesh', + description: '' + }, }, - - sidebar: true - } + themeConfig: { + locales: { + '/': { + selectText: 'Languages', + label: 'English', + ariaLabel: 'Languages', + nav: [ + {text: 'Community', link: '/en/community/'}, + { + text: 'Blog', + link: '/en/blog/' + }, + { + text: 'Documentation', link: '/en/documentation/' + }, + {text: 'Github', link: 'https://github.com/WeBankFinTech/EventMesh'}, + ], + }, + '/en/': { + selectText: 'Languages', + label: 'English', + ariaLabel: 'Languages', + nav: [ + {text: 'Community', link: '/en/community/'}, + { + text: 'Blog', + link: '/en/blog/' + }, + { + text: 'Documentation', link: '/en/documentation/' + }, + {text: 'Github', link: 'https://github.com/WeBankFinTech/EventMesh'}, + ], + }, + '/cn/': { + // 多语言下拉菜单的标题 + selectText: '选择语言', + // 该语言在下拉菜单中的标签 + label: '简体中文', + nav: [ + {text: '社区', link: '/cn/community/'}, + { + text: '博客', + link: '/cn/blog/' + }, + { + text: '文档', link: '/en/documentation/' + }, + {text: 'Github', link: 'https://github.com/WeBankFinTech/EventMesh'}, + ], + } + }, + + sidebar: true + } } diff --git a/docs/README.md b/docs/README.md index 7dec671ded..f36c5eeb70 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,12 +1,15 @@ -[![Build Status](https://www.travis-ci.org/WeBankFinTech/DeFiBus.svg?branch=master)](https://www.travis-ci.org/WeBankFinTech/EventMesh) -[![Coverage Status](https://coveralls.io/repos/github/WeBankFinTech/DeFiBus/badge.svg?branch=master)](https://coveralls.io/github/WeBankFinTech/EventMesh?branch=master) -[![GitHub release](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/WeBankFinTech/EventMesh/releases) +# Apache EventMesh (Incubating) +[![Build Status](https://www.travis-ci.org/apache/incubator-eventmesh.svg?branch=develop)](https://www.travis-ci.org/github/apache/incubator-eventmesh.svg?branch=develop) +[![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) [点我查看中文版](cn/README.md) ## What is Event Mesh? -EventMesh is a dynamic cloud-native eventing infrastruture 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. + +EventMesh is a dynamic cloud-native eventing infrastruture 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](images/eventmesh-define.png) **EventMesh Architecture:** @@ -17,21 +20,27 @@ EventMesh is a dynamic cloud-native eventing infrastruture used to decouple the ![architecture2](images/eventmesh-panels.png) -The event mesh allows events from one application to be dynamically routed to any other application. -General functions of the event mesh: +The event mesh allows events from one application to be dynamically routed to any other application. General functions +of the event mesh: + * Event driven; * Event governance; * Dynamic routing; * Cloud native Dependent components: -* [RocketMQ](https://github.com/apache/rocketmq):RocketMQ is a distributed messaging and streaming platform with low latency, high performance and reliability, trillion-level capacity and flexible scalability. + +* [RocketMQ](https://github.com/apache/rocketmq):RocketMQ is a distributed messaging and streaming platform with low + latency, high performance and reliability, trillion-level capacity and flexible scalability. Key components: -* eventmesh-runtime : an middleware to transmit events between event producers and consumers, support cloud native apps and microservices + +* 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, and will support gRPC in the future ## RoadMap + | version | feature | | ---- | ---- | | v1.0.0 |Support pub/sub, http api, java-sdk| @@ -51,20 +60,26 @@ Key components: | |Support c/go/python/NodeJs/wasm SDK| ## Quick Start + 1. Build and deploy event-store(RocketMQ), see [instruction](https://rocketmq.apache.org/docs/quick-start/). -2. Build and deploy eventmesh-runtime, see instruction ['eventmesh-runtime quickstart'](instructions/eventmesh-runtime-quickstart.md). -3. Run eventmesh-sdk-java demo, see instruction ['eventmesh-sdk-java quickstart'](instructions/eventmesh-sdk-java-quickstart.md). +2. Build and deploy eventmesh-runtime, see + instruction ['eventmesh-runtime quickstart'](en/instructions/eventmesh-runtime-quickstart.md). +3. Run eventmesh-sdk-java demo, see + instruction ['eventmesh-sdk-java quickstart'](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. +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/WeBankFinTech/EventMesh/issues) ## License + [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation ## Contacts + WeChat group: ![wechat_qr](images/mesh-helper.png) diff --git a/docs/cn/README.md b/docs/cn/README.md index 276999882c..59b5fdde9e 100644 --- a/docs/cn/README.md +++ b/docs/cn/README.md @@ -1,9 +1,10 @@ -[![Build Status](https://www.travis-ci.org/WeBankFinTech/DeFiBus.svg?branch=master)](https://www.travis-ci.org/WeBankFinTech/EventMesh) -[![Coverage Status](https://coveralls.io/repos/github/WeBankFinTech/DeFiBus/badge.svg?branch=master)](https://coveralls.io/github/WeBankFinTech/EventMesh?branch=master) -[![GitHub release](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/WeBankFinTech/EventMesh/releases) +# Apache EventMesh (Incubating) +[![Build Status](https://www.travis-ci.org/apache/incubator-eventmesh.svg?branch=develop)](https://www.travis-ci.org/github/apache/incubator-eventmesh.svg?branch=develop) +[![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) ## 什么是Event Mesh? + EventMesh是一个动态的云原生事件驱动架构基础设施,用于分离应用程序和后端中间件层,它支持广泛的用例,包括复杂的混合云、使用了不同技术栈的分布式架构。 ![architecture1](../images/eventmesh-define.png) @@ -16,8 +17,7 @@ EventMesh是一个动态的云原生事件驱动架构基础设施,用于分 ![architecture2](../images/eventmesh-panels.png) -Event Mesh允许将来自一个应用程序的事件动态路由到任何其他应用程序. -Event Mesh的一般功能: +Event Mesh允许将来自一个应用程序的事件动态路由到任何其他应用程序. Event Mesh的一般功能: * 事件驱动; * 事件治理; @@ -25,13 +25,16 @@ Event Mesh的一般功能: * 云原生 依赖部件: + * [RocketMQ](https://github.com/apache/rocketmq):RocketMQ是一个分布式消息流平台,具有低延迟、高性能和可靠性、万亿级容量和灵活的可伸缩性。 关键部件: + * eventmesh-runtime:一种中间件,用于在事件产生者和使用者之间传输事件,支持云原生应用程序和微服务 * eventmesh-sdk-java:当前支持HTTP和TCP协议,未来会支持gRPC等 ## RoadMap + | version | feature | | ---- | ---- | | v1.0.0 |Support pub/sub, http api, java-sdk| @@ -51,20 +54,24 @@ Event Mesh的一般功能: | |Support c/go/python/NodeJs/wasm SDK| ## 快速开始 + 1. 构建并部署event-store(RocketMQ), 请参见[说明](https://rocketmq.apache.org/docs/quick-start/) -2. 构建并部署eventmesh-runtime,请参见说明['eventmesh-runtime quickstart']( instructions/eventmesh-runtime-quickstart.md) -3. 运行eventmesh-sdk-java演示,请参见说明['eventmesh-sdk-java quickstart'](instructions/eventmesh-sdk-java-quickstart.md) +2. 构建并部署eventmesh-runtime,请参见说明['eventmesh-runtime quickstart'](instructions/eventmesh-runtime-quickstart.zh-CN.md) +3. 运行eventmesh-sdk-java演示,请参见说明['eventmesh-sdk-java quickstart'](instructions/eventmesh-sdk-java-quickstart.zh-CN.md) ## 贡献 -永远欢迎参与共建, 请参阅[贡献](CONTRIBUTING.md)了解详细指南 -您可以从问题开始. -[GitHub Issues](https://github.com/WeBankFinTech/EventMesh/issues) +永远欢迎参与共建, 请参阅[贡献](../../CONTRIBUTING.zh-CN.md)了解详细指南 + +您可以从问题开始. +[GitHub Issues](https://github.com/apache/incubator-eventmesh/issues) ## License + [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation ## 联系人 + 微信群: ![wechat_qr](../images/mesh-helper.png) diff --git a/docs/cn/features/0-introduction.md b/docs/cn/features/0-introduction.md deleted file mode 100644 index 8e8558ca73..0000000000 --- a/docs/cn/features/0-introduction.md +++ /dev/null @@ -1,49 +0,0 @@ -# DeFiBus -       -**DeFiBus=RPC+MQ,是基于开源消息中间件打造的安全可靠的分布式金融级消息总线。DeFibus不仅提供了RPC同步调用,还提供了MQ的异步事件通知、事件组播和广播等常用服务调用和消息模式,同时增加了应用多中心多活、服务就近、灰度发布等分布式场景下的高可用能力。在对于机器故障的容错能力方面的增强,也让消息总线的服务更加稳定可靠,为业务提供7x24的服务。** - -### 整体架构 -
- -![architecture1](../../../docs/images/features/a-distributing-architecture-in-financial.png) - -
- -![architecture2](../../../docs/images/features/architecture-p1.png) - -DeFiBus主要包括以下几个组件(模块): - -* **Broker**:通过轻量的Topic和Queue机制提供消息存储功能。Broker定期将Topic信息上报到NameServer中,同集群中的Broker实例上报的NameServer必须保持一致,避免路由信息不一致。 - -* **NameServer**:NameServer提供Topic的发现和路由,每一个NameServer接受Broker上报的Topic信息,并维护Topic的路由信息供客户端查询。 - -* **GSL**:全局服务定位(Global Service Location)服务提供服务级别的路由发现。服务可以部署在不同的区域(比如不同的数据中心、逻辑分区等),服务请求方在请求某一个具体服务时,无需关注服务部署的区域,GSL能够根据服务发现规则自动定位到具体的服务,将服务信息返回给客户端。 - -* **SGS**:服务治理系统(Service Government System)负责全局的服务管理,包括服务的申请、服务部署规划、服务下线等服务全生命周期的管理。在DeFiBus中,服务与Topic一一对应,Topic的名称由对应的服务按照一定的规则来命名。Topic的创建、更新和删除由SGS统一管理。SGS在服务的部署区域对应的Broker集群中创建Topic之后,将更新全局服务路由数据,供GSL定位服务使用。 - -* **EventMesh**:服务代理(EventMesh)提供HTTP接入方式,同时允许按照协议规范开发的C、GO、Python等其他语言客户端的接入。 - -### 服务和Topic的定义 -       -DeFiBus把服务和Topic做了一一对应,每个服务必须对应一个Topic。Topic根据服务的唯一ID和服务的部署区域来命名。每个服务需要有服务的唯一标识,可以用数字ID或者字符串来表示。每个部署区域使用3位长度的字符串(限数字和字母构成)表示。 -Topic按照如下格式来命名: -``` -[区域代码]-[服务唯一ID] -``` - -比如,余额查询服务的服务ID为20190001表示,部署在“A10”这个区域,那么该服务在A10区域的Topic就命名为“A10-20190001”。Topic的命名规则 - - -### 特性列表: -* [RPC调用:即“Request-Reply”模式,支持系统间的同步调用](docs/cn/features/1-request-response-call.md) -* 消息发布/订阅:消息的发布和订阅 -* [灰度发布:服务级别的灰度发布](docs/cn/features/2-dark-launch.md) -* [熔断机制:应用实例级别的熔断](docs/cn/features/3-circuit-break-mechanism.md) -* [服务就近:就近进行服务的请求和响应,减少跨区调用](docs/cn/features/4-invoke-service-nearby.md) -* [应用多活:应用多中心多活](docs/cn/features/5-multi-active.md) -* [动态扩缩队列 :自适应应用实例数量,动态调整队列个数](docs/cn/features/6-dynamic-adjust-queue.md) -* [容错机制:故障和错误隔离](docs/cn/features/8-fault-tolerant.md) -* 服务路由和定位:动态路由及定位(后续开源) -* 服务代理:HTTP及多语言的代理(后续开源) -* 服务治理:服务元数据的管理(后续开源) -* 平滑升级:平滑升级、平滑扩容(后续开源) \ No newline at end of file diff --git a/docs/cn/features/1-request-response-call.md b/docs/cn/features/1-request-response-call.md deleted file mode 100644 index 1feabaf457..0000000000 --- a/docs/cn/features/1-request-response-call.md +++ /dev/null @@ -1,34 +0,0 @@ -## 1. Request-Reply同步调用 - -       -Request-Reply同步调用指的是请求方发出一条消息之后,需要响应方在消费完这条消息后回复一个响应结果。 - -
- -![RR](../../images/features/RR-call-p1.png) - -
- -整个调用过程包含了两个消息的产生和消费过程。 -**1.请求方产生请求消息,服务响应方消费这条请求消息** -       -请求方根据服务提供方的协议将请求内容设置到消息体中,并将消息发送到Broker上。服务响应方订阅相应的Topic,从Broker上获取到请求消息,并消费。 - -**2.服务响应方产生响应消息,请求方接收这条响应消息** -       -服务响应方收到请求消息后,执行相应的处理,并将请求结果设置到响应消息的消息体中,将响应消息发送到Broker上。请求方接收响应消息的方式采用的是Broker推送的形式,而不是由Producer订阅的方式,从而使得响应消息能够精准回到发出请求消息的实例上。 - -       -DeFiBus在每条请求消息中增加REPLY_TO属性来唯一标识每一个请求方实例。在创建响应消息时将REPLY_TO属性透传到响应消息中。Broker收到响应消息后,根据REPLY_TO属性,查找出对应的请求方实例的连接,将响应消息推送给该请求方实例。 - - ---- -#### Links: -* [架构介绍](../../../README.md) -* [Request-Reply调用](docs/cn/features/1-request-response-call.md) -* [灰度发布](docs/cn/features/2-dark-launch.md) -* [熔断机制](docs/cn/features/3-circuit-break-mechanism.md) -* [服务就近](docs/cn/features/4-invoke-service-nearby.md) -* [应用多活](docs/cn/features/5-multi-active.md) -* [动态扩缩队列](docs/cn/features/6-dynamic-adjust-queue.md) -* [容错机制](docs/cn/features/8-fault-tolerant.md) \ No newline at end of file diff --git a/docs/cn/features/10-flow-control.md b/docs/cn/features/10-flow-control.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/docs/cn/features/2-dark-launch.md b/docs/cn/features/2-dark-launch.md deleted file mode 100644 index e6e7e20119..0000000000 --- a/docs/cn/features/2-dark-launch.md +++ /dev/null @@ -1,24 +0,0 @@ -## 2.灰度发布 - -       -同一个消费组中的消费者实例通常订阅的Topic是相同的。在有新业务上线时,我们希望仅仅在个别实例上进行灰度,验证通过之后再进行全量。DeFiBus提供了灰度发布的能力,同一个消费组中,允许不同消费者实例订阅不同的Topic,只有订阅了某个具体Topic的实例才能够收到这个Topic的消息,同消费组中没有订阅这个Topic的实例不会收到消息。 - -       -假设一个消费组有3个消费者实例,上线初期只涉及到Topic1和Topic2。当业务扩展,需要增加Topic3的订阅时,可以先灰度其中一个实例,验证Topic3在灰度实例上执行正常之后,逐步再替换其他实例。在这期间,实例1和实例2不会收到Topic3的消息。 - -
- -![avater](../../images/features/dark-launch-p1.png) - -
- ---- -#### Links: -* [架构介绍](../../../README.md) -* [Request-Reply调用](docs/cn/features/1-request-response-call.md) -* [灰度发布](docs/cn/features/2-dark-launch.md) -* [熔断机制](docs/cn/features/3-circuit-break-mechanism.md) -* [服务就近](docs/cn/features/4-invoke-service-nearby.md) -* [应用多活](docs/cn/features/5-multi-active.md) -* [动态扩缩队列](docs/cn/features/6-dynamic-adjust-queue.md) -* [容错机制](docs/cn/features/8-fault-tolerant.md) \ No newline at end of file diff --git a/docs/cn/features/3-circuit-break-mechanism.md b/docs/cn/features/3-circuit-break-mechanism.md deleted file mode 100644 index 06eec22ae3..0000000000 --- a/docs/cn/features/3-circuit-break-mechanism.md +++ /dev/null @@ -1,25 +0,0 @@ -## 3.熔断 -       -DeFiBus基于队列来做消费端的负载均衡,对同一个消费组,除广播模式外,每个队列只由一个消费者实例消费。当一个实例处理能力下降或者异常出现消息堆积时,为了避免堆积情况继续加剧,DeFiBus会触发队列的熔断,此时生产者实例在感知到队列熔断之后,会优先把消息发送到其他没有熔断的队列上,暂停往熔断队列上写入新消息。当堆积消除后,熔断被解除,生产者恢复往该队列发送消息。 - -       -DeFiBus对每个Topic定义了深度的属性,表示Topic的队列允许堆积的最大消息条数。消息堆积数表示队列中尚未下发给消费者实例的消息条数,可由队列中最新一条消息的offset与消费者实例已经获取到的消息的offset的差值计算。 -
- -![offset](../../../docs/images/features/circuit-break-p1.png) - -
- -       -当Consumer出现异常或者触发了流控,Consumer拉消息过程受阻,队列的DeliverOffset停止不前,新消息持续写入,MaxOffset不断变大,最终MaxOffset与DeliverOffset将超过Topic的最大深度限制,触发队列熔断。 - ---- -#### Links: -* [架构介绍](../../../README.md) -* [Request-Reply调用](docs/cn/features/1-request-response-call.md) -* [灰度发布](docs/cn/features/2-dark-launch.md) -* [熔断机制](docs/cn/features/3-circuit-break-mechanism.md) -* [服务就近](docs/cn/features/4-invoke-service-nearby.md) -* [应用多活](docs/cn/features/5-multi-active.md) -* [动态扩缩队列](docs/cn/features/6-dynamic-adjust-queue.md) -* [容错机制](docs/cn/features/8-fault-tolerant.md) diff --git a/docs/cn/features/4-invoke-service-nearby.md b/docs/cn/features/4-invoke-service-nearby.md deleted file mode 100644 index 209940cbfd..0000000000 --- a/docs/cn/features/4-invoke-service-nearby.md +++ /dev/null @@ -1,29 +0,0 @@ -## 4.服务就近 -       -为了保证高可用,服务的部署通常分布在多个机房、区域。我们希望服务之间能够就近调用,减少跨机房跨区域网络访问的时延问题。对此,DeFiBus在Broker和客户端上都增加了区域的属性来标识实例属于哪个区域。对于Producer,消息会优先发往同区域内的Broker集群上;对于Consumer,则优先监听同区域内的Queue;当一个区域内没有Consumer实例监听时,则由其他区域的Consumer实例跨区域监听。 - -### 就近发送 -       -在创建Producer时,通过设置```DeFiBusClientConfig.setClusterPrefix("your region")```来标识Producer实例所在的区域。Producer在每次发送消息会先选则一个Queue来作为发送的目标队列。当启用就近发送时,Producer优先选择与自己同区域内的Queue,当本区域内没有可用Queue时,则选择其他区域的Queue。 -
- -
- -### 就近监听 -       -就近监听指的是Consumer在做负载均衡分配Queue的时候,每个区域内的Queue只由该区域内的Consumer监听和消费,当且仅当一个区域内没有订阅该Topic的Consumer时,由其他区域订阅了该Topic的Consumer跨区域监听和消费这些Queue。虽然Consumer是在同区域内就近消费,但仍通过心跳维持跨区域的连接,以保证能够随时跨区域接管消费。 - -
- -
- ---- -#### Links: -* [架构介绍](../../../README.md) -* [Request-Reply调用](docs/cn/features/1-request-response-call.md) -* [灰度发布](docs/cn/features/2-dark-launch.md) -* [熔断机制](docs/cn/features/3-circuit-break-mechanism.md) -* [服务就近](docs/cn/features/4-invoke-service-nearby.md) -* [应用多活](docs/cn/features/5-multi-active.md) -* [动态扩缩队列](docs/cn/features/6-dynamic-adjust-queue.md) -* [容错机制](docs/cn/features/8-fault-tolerant.md) \ No newline at end of file diff --git a/docs/cn/features/5-multi-active.md b/docs/cn/features/5-multi-active.md deleted file mode 100644 index f24366630b..0000000000 --- a/docs/cn/features/5-multi-active.md +++ /dev/null @@ -1,18 +0,0 @@ -## 5.同城多中心多活 -       -同城多中心多活指的是应用的多活,在DeFiBus集群正常运行的情况下,应用部署在多个数据中心,一个数据中心的应用实例全部挂掉后,DeFiBus能够自动将应用流量切换到另一个数据中心的应用实例上,保证应用能够持续稳定地提供服务而不中断。同城多中心多活得益于DeFiBus的服务就近特性,结合应用部署的规划,使得正常情况下服务调用发生在同一个数据中心,当一个中心的应用出现故障时,能够有其他中心的实例接管服务。 - -
- -
- ---- -#### Links: -* [架构介绍](../../../README.md) -* [Request-Reply调用](docs/cn/features/1-request-response-call.md) -* [灰度发布](docs/cn/features/2-dark-launch.md) -* [熔断机制](docs/cn/features/3-circuit-break-mechanism.md) -* [服务就近](docs/cn/features/4-invoke-service-nearby.md) -* [应用多活](docs/cn/features/5-multi-active.md) -* [动态扩缩队列](docs/cn/features/6-dynamic-adjust-queue.md) -* [容错机制](docs/cn/features/8-fault-tolerant.md) \ No newline at end of file diff --git a/docs/cn/features/6-dynamic-adjust-queue.md b/docs/cn/features/6-dynamic-adjust-queue.md deleted file mode 100644 index 9c27b7deb1..0000000000 --- a/docs/cn/features/6-dynamic-adjust-queue.md +++ /dev/null @@ -1,35 +0,0 @@ -## 自动伸缩Queue -       -在同一个消费组内,每个队列只由一个实例消费。当队列数小于消费者实例数时,会有部分消费者实例分不到队列;反之,当队列数大于消费者实例数时,每个消费者需要消费多个队列。队列数不是消费者实例数的整数倍时,则会出现部分实例需要消费比同组内的其他实例更多的队列,出现负载不均衡问题。 - -       -DeFiBus提供了队列数量自动调整的特性。当有Consumer新注册或者去注册时,Broker触发队列的自动伸缩,根据当前在线的消费者实例个数,增加或者减少队列个数,使队列个数与消费者实例数保持一致。 - -       -当队列数需要增加时,首先调整Topic的ReadQueueNum,将可读的队列数扩增;10s之后,再调整Topic的WriteQueueNum,将可写的队列数扩增。这样使得新扩增的队列能够先被消费者感知并监听上,然后才让生产者感知到,往新队列上发送消息,是扩增操作更平滑。 - -
- -
- -       -当队列数需要减少时,首先调整Topic的WriteQueueNum,将可写的队列数缩减;5分钟(默认,可配置)后先检查即将被缩减的队列中是否有消息没有被消费完,如果有,则继续延迟缩减操作,使消费者能够继续消费完队列中的消息;如果没有,则调整ReadQueueNum,将可写的队列数缩减。 - -
- -
- -       -对于多个消费组订阅相同Topic并且是集群消费模式时,在计算扩缩的队列个数时,以最大的消费组的消费者实例数为准,保证拥有最多实例数的消费组内每个消费者实例都能够分到Queue进行消费。 - - ---- -#### Links: -* [架构介绍](../../../README.md) -* [Request-Reply调用](docs/cn/features/1-request-response-call.md) -* [灰度发布](docs/cn/features/2-dark-launch.md) -* [熔断机制](docs/cn/features/3-circuit-break-mechanism.md) -* [服务就近](docs/cn/features/4-invoke-service-nearby.md) -* [应用多活](docs/cn/features/5-multi-active.md) -* [动态扩缩队列](docs/cn/features/6-dynamic-adjust-queue.md) -* [容错机制](docs/cn/features/8-fault-tolerant.md) \ No newline at end of file diff --git a/docs/cn/features/7-isolation-mechanism.md b/docs/cn/features/7-isolation-mechanism.md deleted file mode 100644 index 298efc461d..0000000000 --- a/docs/cn/features/7-isolation-mechanism.md +++ /dev/null @@ -1,23 +0,0 @@ -## 隔离机制 -Producer在往Topic发送消息时,会按照MessageQueueSelector定义的选择策略,从Topic的所有MessageQueue中选择一个作为目标队列发送消息。 -当队列发生熔断,或者Broker故障导致队列发送消息异常时,如果没有对这些队列进行特殊处理,下次再轮到发这个队列的时候仍然可能失败。 - -DeFiBus提供异常队列的隔离机制,当往某个队列发送消息失败时,将队列标记为隔离状态,在隔离过期之前将不再往这个队列发送消息,避免再次失败,降低失败概率。 - -异常队列隔离机制分为两步: -**-发现并标记队列为隔离** -在发送回调中更新发送队列的健康状态,如果执行的是onSuccess分支,则标记队列为健康,去除队列的隔离标记;如果执行的是onException分支,则标记队列为隔离状态。 - -**-不选择隔离中的队列发送消息** -在MessageQueueSelector中实现隔离机制的过滤逻辑,每次进行队列的选择时,优先从没有标记为隔离的队列中选择。当所有队列都被标记为隔离时,则从所有队列中选择,保证每次都要选出一个队列。 - ---- -#### Links: -* [架构介绍](../../../README.md) -* [Request-Reply调用](docs/cn/features/1-request-response-call.md) -* [灰度发布](docs/cn/features/2-dark-launch.md) -* [熔断机制](docs/cn/features/3-circuit-break-mechanism.md) -* [服务就近](docs/cn/features/4-invoke-service-nearby.md) -* [应用多活](docs/cn/features/5-multi-active.md) -* [动态扩缩队列](docs/cn/features/6-dynamic-adjust-queue.md) -* [容错机制](docs/cn/features/8-fault-tolerant.md) \ No newline at end of file diff --git a/docs/cn/features/8-fault-tolerant.md b/docs/cn/features/8-fault-tolerant.md deleted file mode 100644 index f118c9d311..0000000000 --- a/docs/cn/features/8-fault-tolerant.md +++ /dev/null @@ -1,50 +0,0 @@ -## 8.容错机制 -       -在金融场景下,对可用性和稳定性的要求非常高,中间件对机器故障、网络故障、应用故障以及中间件本身的故障等常见故障场景需要有容错能力,降低故障带来的影响。 - -### 隔离机制 -##### 1. Producer端的隔离 -       -Producer在往Topic发送消息时,会按照MessageQueueSelector定义的选择策略,从Topic的所有MessageQueue中选择一个作为目标队列发送消息。 -当队列发生熔断,或者Broker故障导致队列发送消息异常时,如果没有对这些队列进行特殊处理,下次再轮到发这个队列的时候仍然可能失败。 - -       -DeFiBus提供异常队列的隔离机制,当往某个队列发送消息失败时,将队列标记为隔离状态,在隔离过期之前将不再往这个队列发送消息,避免再次失败,降低失败概率。 - -异常队列隔离机制分为两步: -**-发现并标记队列为隔离** -       -在发送回调中更新发送队列的健康状态,如果执行的是onSuccess分支,则标记队列为健康,去除队列的隔离标记;如果执行的是onException分支,则标记队列为隔离状态。 - -**-不选择隔离中的队列发送消息** -       -在MessageQueueSelector中实现隔离机制的过滤逻辑,每次进行队列的选择时,优先从没有标记为隔离的队列中选择。当所有队列都被标记为隔离时,则从所有队列中选择,保证每次都要选出一个队列。 - - -##### 2. Consumer端的隔离 - -       -Consumer由拉消息线程只负责把拉消息请求以异步发送的形式发送出去。在正常情况下,每次拉消息请求的执行都很快,不会有卡顿。一旦有Broker故障导致PullRequest的执行发生了卡顿,则该Consumer监听的所有Queue都会因为PullRequest执行的延迟而出现消息消费延迟。对于RR同步请求的场景,这种是不能够接受的。 - -       -创建连接采用的是同步建立连接的策略,线程执行创建新连接时必须等待连接创建完成或者连接超时。当有Broker故障连不上时,就算是异步发送,也会因为同步等待连接建立而阻塞。此时就会出现一个Broker的故障导致其他健康Broker的消息消费出现延迟。 - -       -DeFiBus在Consumer拉消息的过程中增加了对拉消息任务的隔离,此处的隔离指的是将疑似有问题的任务隔离到另外的线程中执行,保证拉消息线程能够正常处理其他正常的任务。当发现执行拉消息耗时超过设定的阈值时,将该拉消息任务对应的Broker列入“隔离名单”中,在隔离过期之前,隔离Broker的拉消息请求都转交给另外线程执行,避免阻塞拉消息主线程,从而避免故障的Broker影响健康Broker的消息消费时效。 - -### 连接空闲机制 - -       -当连接的读或者写空闲超过60秒时,将主动断开连接。 - - ---- -#### Links: -* [架构介绍](../../../README.md) -* [Request-Reply调用](docs/cn/features/1-request-response-call.md) -* [灰度发布](docs/cn/features/2-dark-launch.md) -* [熔断机制](docs/cn/features/3-circuit-break-mechanism.md) -* [服务就近](docs/cn/features/4-invoke-service-nearby.md) -* [应用多活](docs/cn/features/5-multi-active.md) -* [动态扩缩队列](docs/cn/features/6-dynamic-adjust-queue.md) -* [容错机制](docs/cn/features/8-fault-tolerant.md) \ No newline at end of file diff --git a/docs/cn/features/9-publish-type.md b/docs/cn/features/9-publish-type.md deleted file mode 100644 index 74c3446d77..0000000000 --- a/docs/cn/features/9-publish-type.md +++ /dev/null @@ -1,35 +0,0 @@ -## 2. 单播、多播、广播 - -       -DeFiBus支持单播、多播、广播消费模式。 - -### 单播 - -
- -![unicast](../../images/features/unicast.png) - -
- -单播模式下,topic只被一个消费组监听;接收消息时,消费组内有且仅有一个实例会收到消息。 - -### 多播 - -
- -![multicast](../../images/features/multicast.png) - -
- -多播模式下,topic被多个消费组监听;接收消息时,每个消费组内有且仅有一个实例会收到消息。 - - -### 广播 - -
- -![broadcast](../../images/features/broadcast.png) - -
- -广播模式下,监听此topic的每个消费组中的每个实例都需要收到消息。 \ No newline at end of file diff --git a/docs/cn/features/https.zh-CN.md b/docs/cn/features/https.zh-CN.md index a4aadef2d8..fa1244f949 100644 --- a/docs/cn/features/https.zh-CN.md +++ b/docs/cn/features/https.zh-CN.md @@ -9,11 +9,10 @@ config env varible -Dssl.server.protocol=TLSv1.1 //默认值 TLSv1.1 -Dssl.server.cer=sChat2.jks //把文件放到启动脚本start.sh 指定的conPath目录下 -Dssl.server.pass=sNetty - ``` - 2.在eventmesh-sdk-java 中配置 + ``` //创建producer LiteClientConfig liteClientConfig = new liteClientConfig(); diff --git a/docs/cn/instructions/eventmesh-runtime-protocol.zh-CN.md b/docs/cn/instructions/eventmesh-runtime-protocol.zh-CN.md index 692f46d67d..a3d152dbdc 100644 --- a/docs/cn/instructions/eventmesh-runtime-protocol.zh-CN.md +++ b/docs/cn/instructions/eventmesh-runtime-protocol.zh-CN.md @@ -20,8 +20,6 @@ 消息体(body):长度 = length - headerLength - 4 - 4 ``` - - #### 2. 业务逻辑层 + 消息组成 @@ -45,8 +43,6 @@ public class Header { } ``` - - + 详解 消息头(header):类型为Header,Header中有Command字段,用于区分不同的消息类型 @@ -61,8 +57,6 @@ public class Header { | REQUEST_TO_SERVER, REQUEST_TO_CLIENT, RESPONSE_TO_SERVER, RESPONSE_TO_CLIENT, ASYNC_MESSAGE_TO_SERVER, ASYNC_MESSAGE_TO_CLIENT, BROADCAST_MESSAGE_TO_SERVER, BROADCAST_MESSAGE_TO_CLIENT, ASYNC_MESSAGE_TO_CLIENT_ACK, BROADCAST_MESSAGE_TO_CLIENT_ACK, RESPONSE_TO_CLIENT_ACK, REQUEST_TO_CLIENT_ACK | OpenMessage | | REDIRECT_TO_CLIENT | RedirectInfo | - - #### 3. Client 与 Eventmesh-Runtime(Server)交互场景详解 ```java @@ -117,8 +111,6 @@ public enum Command { } ``` - - #### 4. Client发起交互 | 场景 | Client向Server发送消息命令字 | Server回复Client消息的命令字 | 说明 | @@ -134,8 +126,6 @@ public enum Command { | 发送广播事件 | BROADCAST_MESSAGE_TO_SERVER | BROADCAST_MESSAGE_TO_SERVER_ACK | | | 客户端主动断连 | CLIENT_GOODBYE_REQUEST | CLIENT_GOODBYE_RESPONSE | | - - #### 5. Server发起交互 | 场景 | Server向Client发送消息命令字 | Client回复Server消息命令字 | 说明 | @@ -148,26 +138,20 @@ public enum Command { | 服务端进行重定向 | REDIRECT_TO_CLIENT | 无 | | | | | | | - #### 6. 消息类型 + + 发送RR消息 ![rr-msg](../../images/protocol/eventmesh-rr-msg.png) - - + 发送异步单播消息 ![async-msg](../../images/protocol/eventmesh-async-msg.png) - - + 发送广播消息 ![broadcast-msg](../../images/protocol/eventmesh-broadcast-msg.png) - - ## HTTP协议文档 Java类`LiteMessage`的`content`字段表示一个特殊的协议,因此,如果您要使用eventmesh-sdk-java的http-client,则只需设计协议的`content`即可。`LiteMessage`组成如下: @@ -189,18 +173,12 @@ public class LiteMessage { } ``` - - #### 1. 消息发送方式与组成 - - **消息发送方式**:POST方式 **消息组成**:请求头(RequestHeader) + 请求体(RequestBody) - - + 心跳消息 **RequestHeader** @@ -227,8 +205,6 @@ public class LiteMessage { | clientType | 客户端类型 | | heartbeatEntities | 心跳实体,包含topic、url等信息 | - - + 订阅消息: **RequestHeader** @@ -242,8 +218,6 @@ public class LiteMessage { | topic | 客户端订阅的topic | | url | topic对应的url | - - + 取消订阅消息: **RequestHeader** @@ -254,8 +228,6 @@ public class LiteMessage { 与订阅消息一致 - - + 发送异步事件: **RequestHeader** @@ -272,8 +244,6 @@ public class LiteMessage { | bizSeqNo | 客户端请求业务流水号 | | uniqueId | 客户端请求消息唯一标识 | - - #### 2. Client发起交互 | 场景 | Client向Server发送消息请求码 | Server回复Client消息的响应码 | 说明 | @@ -283,8 +253,6 @@ public class LiteMessage { | 取消订阅 | UNSUBSCRIBE(207) | SUCCESS(0)/EVENTMESH_UNSUBSCRIBE_ERROR(18) | | | 发送异步事件 | MSG_SEND_ASYNC(104) | SUCCESS(0)/EVENTMESH_SEND_ASYNC_MSG_ERR(14) | | - - #### 3. Server发起交互 | 场景 | Server向Client发送消息请求码 | Client回复Server消息响应码 | 说明 | diff --git a/docs/cn/instructions/eventmesh-runtime-quickstart.zh-CN.md b/docs/cn/instructions/eventmesh-runtime-quickstart.zh-CN.md index 1beb30c715..adc9703796 100644 --- a/docs/cn/instructions/eventmesh-runtime-quickstart.zh-CN.md +++ b/docs/cn/instructions/eventmesh-runtime-quickstart.zh-CN.md @@ -1,35 +1,34 @@

Eventmesh-runtime快速入门说明

- -## 1 远程部署 +## 1 远程部署 ### 1.1 依赖 ``` 建议使用64位操作系统,建议使用Linux / Unix; 64位JDK 1.8+; -Gradle至少为5.6, 推荐 5.6.* +Gradle至少为7.0, 推荐 7.0.* ``` -### 1.2 下载源码 +### 1.2 下载源码 -[https://github.com/WeBankFinTech/EventMesh](https://github.com/WeBankFinTech/EventMesh) +[https://github.com/apache/incubator-eventmesh](https://github.com/apache/incubator-eventmesh) 您将获得**EventMesh-master.zip** ### 1.3 构建源码 ```$ xslt unzip EventMesh-master.zip -cd / *您的部署路径* /EventMesh-master/eventmesh-runtime +cd / *您的部署路径* /EventMesh-master gradle clean dist tar -x test ``` + 您将在目录/ *您的部署路径* /EventMesh-master/eventmesh-runtime/dist中获得**eventmesh-runtime_1.0.0.tar.gz** ### 1.4 部署 - 部署eventmesh-runtime - ```$ xslt upload eventmesh-runtime_1.0.0.tar.gz tar -zxvf eventmesh-runtime_1.0.0.tar.gz @@ -38,9 +37,8 @@ cd bin cd ../bin sh start.sh ``` -如果看到"EventMeshTCPServer[port=10000] started....",则说明设置成功。 - +如果看到"EventMeshTCPServer[port=10000] started....",则说明设置成功。 ## 2 本地构建运行 @@ -48,7 +46,7 @@ sh start.sh 同上述步骤 1.1 -### 2.2 下载源码 +### 2.2 下载源码 同上述步骤 1.2 @@ -57,6 +55,7 @@ sh start.sh **2.3.1 项目结构说明:** ![project-structure](../../images/project-structure.png) + - eventmesh-common : eventmesh公共类与方法模块 - eventmesh-connector-api : eventmesh插件接口定义模块 - eventmesh-connector-rocketmq : eventmesh rocketmq插件模块 @@ -69,11 +68,12 @@ sh start.sh **2.3.2 配置VM启动参数** ```java --Dlog4j.configurationFile=..\eventmesh-runtime\conf\log4j2.xml --Deventmesh.log.home=..\eventmesh-runtime\logs --Deventmesh.home=..\eventmesh-runtime --DconfPath=..\eventmesh-runtime\conf +-Dlog4j.configurationFile=eventmesh-runtime/conf/log4j2.xml +-Deventmesh.log.home=eventmesh-runtime/logs +-Deventmesh.home=eventmesh-runtime +-DconfPath=eventmesh-runtime/conf ``` +> 注:如果操作系统为Windows, 可能需要将文件分隔符换成\ **2.3.3 配置build.gradle文件** @@ -92,11 +92,9 @@ dependencies { **2.3.4 启动运行** ``` -运行com.webank.eventmesh.starter.StartUp的主要方法 +运行org.apache.eventmesh.starter.StartUp的主要方法 ``` - - ## 3 Docker 运行 ### 3.1 拉取镜像 @@ -113,7 +111,7 @@ dependencies { 在运行容器之前,你需要配置如下文件: -**eventMesh.properties** +**eventMesh.properties** | 配置项 | 默认值 | 备注 | | ---------------------- | ------ | ----------------------- | @@ -137,7 +135,8 @@ vi eventMesh.properties vi rocketmq-client.properties ``` -这两个文件内容可以参考 [eventMesh.properties](https://github.com/WeBankFinTech/EventMesh/blob/develop/eventmesh-runtime/conf/eventMesh.properties) 和 [rocketmq-client.properties](https://github.com/WeBankFinTech/EventMesh/blob/develop/eventmesh-runtime/conf/rocketmq-client.properties) +这两个文件内容可以参考 [eventMesh.properties](https://github.com/apache/incubator-eventmesh/blob/develop/eventmesh-runtime/conf/eventMesh.properties) +和 [rocketmq-client.properties](https://github.com/apache/incubator-eventmesh/blob/develop/eventmesh-runtime/conf/rocketmq-client.properties) ### 3.3 运行 @@ -192,7 +191,7 @@ docker run -d -p 10911:10911 -p 10909:10909 -v `pwd`/data/broker/logs:/root/logs Windows -- Windows系统下运行示例可以参考[这里](https://github.com/WeBankFinTech/EventMesh/blob/develop/docs/cn/instructions/eventmesh-sdk-java-quickstart.zh-CN.md) +- Windows系统下运行示例可以参考[这里](https://github.com/apache/incubator-eventmesh/blob/develop/docs/cn/instructions/eventmesh-sdk-java-quickstart.zh-CN.md) Linux @@ -207,7 +206,7 @@ Linux gradle clean testdist testtar -x test` ``` - 可以在 `/eventmesh-test/build` 目录下获得 **eventmesh-test_1.2.0-SNAPSHOT.tar.gz** + 可以在 `/eventmesh-test/build` 目录下获得 **eventmesh-test_1.2.0-SNAPSHOT.tar.gz** - **修改配置文件** @@ -223,7 +222,7 @@ Linux - **运行** - TCP Sub + TCP Sub ```shell cd bin diff --git a/docs/cn/instructions/eventmesh-sdk-java-quickstart.zh-CN.md b/docs/cn/instructions/eventmesh-sdk-java-quickstart.zh-CN.md index caa52130bf..43df03320f 100644 --- a/docs/cn/instructions/eventmesh-sdk-java-quickstart.zh-CN.md +++ b/docs/cn/instructions/eventmesh-sdk-java-quickstart.zh-CN.md @@ -21,14 +21,13 @@ TCP 和 Http 示例都在**eventmesh-test**模块下 - 启动消费者,订阅上一步骤已经创建的Topic ``` -运行com.webank.eventmesh.tcp.demo.AsyncSubscribe的主要方法 +运行org.apache.eventmesh.tcp.demo.AsyncSubscribe的主要方法 ``` - 启动发送端,发送消息 - ``` -运行com.webank.eventmesh.tcp.demo.AsyncPublish的主要方法 +运行org.apache.eventmesh.tcp.demo.AsyncPublish的主要方法 ```

广播消息

@@ -38,18 +37,18 @@ TCP 和 Http 示例都在**eventmesh-test**模块下 - 启动消费端,订阅上一步骤已经创建的Topic ``` -运行com.webank.eventmesh.tcp.demo.AsyncSubscribeBroadcast的主要方法 +运行org.apache.eventmesh.tcp.demo.AsyncSubscribeBroadcast的主要方法 ``` - 启动发送端,发送广播消息 ``` -运行com.webank.eventmesh.tcp.demo.AsyncPublishBroadcast的主要方法 +运行org.apache.eventmesh.tcp.demo.AsyncPublishBroadcast的主要方法 ``` ### 2. HTTP演示 ->对于http,eventmesh-sdk-java对对于异步事件实现了发送与订阅 +> 对于http,eventmesh-sdk-java对对于异步事件实现了发送与订阅 > >在演示中,Java类`LiteMessage`的`content`字段表示一个特殊的协议,因此,如果您要使用eventmesh-sdk-java的http-client,则只需设计协议的内容并在同一时间提供消费者的应用程序。 @@ -64,13 +63,13 @@ TCP 和 Http 示例都在**eventmesh-test**模块下 异步事件消费端为spring boot demo,运行demo即可启动服务并完成Topic订阅 ``` -运行com.webank.eventmesh.http.demo.sub.SpringBootDemoApplication的主要方法 +运行org.apache.eventmesh.http.demo.sub.SpringBootDemoApplication的主要方法 ``` - 启动发送端,发送消息 ``` -运行com.webank.eventmesh.http.demo.AsyncPublishInstance的主要方法 +运行org.apache.eventmesh.http.demo.AsyncPublishInstance的主要方法 ``` diff --git a/docs/cn/instructions/eventmesh-store-quickstart.zh-CN.md b/docs/cn/instructions/eventmesh-store-quickstart.zh-CN.md index b7bbb9e961..a9ca24c273 100644 --- a/docs/cn/instructions/eventmesh-store-quickstart.zh-CN.md +++ b/docs/cn/instructions/eventmesh-store-quickstart.zh-CN.md @@ -1,6 +1,7 @@ -#Eventmesh-store快速入门说明 +# Eventmesh-store快速入门说明 + +### 依赖 -###依赖 ``` 建议使用64位操作系统,建议使用Linux / Unix; 64位JDK 1.8+; @@ -8,30 +9,38 @@ Gradle至少为5.6, 推荐 5.6.* 4g +可用磁盘用于eventmesh-store服务器 ``` -###下载源码 +### 下载源码 + 下载源代码[https://github.com/WeBankFinTech/DeFiBus](https://github.com/WeBankFinTech/DeFiBus) 您将获得**DefiBus-master.zip** -###构建源码 +### 构建源码 + eventmesh-store在下面的部分采用DeFiBus为例,因为默认情况下,eventmesh依赖于defibus作为存储层,其他工具如Rocketmq等也即将推出。 + ``` unzip DefiBus-master.zip cd / *您的部署路径* / DefiBus-master gradle clean dist tar -x test ``` + 您将在目录/*您的部署路径*/DefiBus-master/build中获得**DeFiBus_1.0.0.tar.gz** -###部署 +### 部署 + - 部署DeFiBusNamesrv + ``` 上传DeFiBus_1.0.0.tar.gz tar -zxvf DeFiBus_1.0.0.tar.gz cd bin sh runnamesrv.sh ``` + 如果在../logs/namesrv.log中看到"Thre Name Server boot success”,则说明已成功设置DeFiBus Namesrv。 -部署DeFiBusBroker + ``` 上传DeFiBus_1.0.0.tar.gz tar -zxvf DeFiBus_1.0.0.tar.gz @@ -40,5 +49,5 @@ cd conf cd ../bin sh runbroker.sh ``` -如果看到"The broker \[YOUR-BROKER-NAME, IP:PORT\] boot success."在../logs/broker.log中, -您可以成功设置eventmesh-store。 \ No newline at end of file + +如果看到"The broker \[YOUR-BROKER-NAME, IP:PORT\] boot success."在../logs/broker.log中, 您可以成功设置eventmesh-store。 \ No newline at end of file diff --git a/docs/cn/instructions/quickstart.zh-CN.md b/docs/cn/instructions/quickstart.zh-CN.md index d5f384075e..e14bf122bf 100644 --- a/docs/cn/instructions/quickstart.zh-CN.md +++ b/docs/cn/instructions/quickstart.zh-CN.md @@ -10,15 +10,15 @@ Gradle至少为5.6, 推荐 5.6.* ### 部署eventmesh-store -阅读更多[这里](eventmesh-store-quickstart.md) +阅读更多[这里](eventmesh-store-quickstart.zh-CN.md) ### 部署eventmesh-runtime -阅读更多[这里](eventmesh-runtime-quickstart.md) +阅读更多[这里](eventmesh-runtime-quickstart.zh-CN.md) ### 运行eventmesh sdk演示 -阅读更多[这里](eventmesh-sdk-java-quickstart.md) +阅读更多[这里](eventmesh-sdk-java-quickstart.zh-CN.md) ### 通信协议 diff --git a/docs/en/README.md b/docs/en/README.md index e89c4f303c..64ca3b5d42 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -1,16 +1,19 @@ -[![Build Status](https://www.travis-ci.org/WeBankFinTech/DeFiBus.svg?branch=master)](https://www.travis-ci.org/WeBankFinTech/EventMesh) -[![Coverage Status](https://coveralls.io/repos/github/WeBankFinTech/DeFiBus/badge.svg?branch=master)](https://coveralls.io/github/WeBankFinTech/EventMesh?branch=master) -[![GitHub release](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/WeBankFinTech/EventMesh/releases) +# Apache EventMesh (Incubating) +[![Build Status](https://www.travis-ci.org/apache/incubator-eventmesh.svg?branch=develop)](https://www.travis-ci.org/github/apache/incubator-eventmesh.svg?branch=develop) +[![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) -[点我查看中文版](/cn/README.md) +[点我查看中文版](../cn/README.md) ## What is Event Mesh? -This figure shows the positioning of the event mesh relative to other similar technologies (such as service mesh) in the application framework. + +This figure shows the positioning of the event mesh relative to other similar technologies (such as service mesh) in the +application framework. ![architecture1](../images/eventmesh-define.png) -Event Mesh is a dynamic plug-in cloud-native basic service layer used to decouple the application and middleware layer. It provides flexible, reliable and fast event distribution, and can be managed. +Event Mesh is a dynamic plug-in cloud-native basic service layer used to decouple the application and middleware layer. +It provides flexible, reliable and fast event distribution, and can be managed. ![architecture1](../images/eventmesh-runtime.png) @@ -18,8 +21,8 @@ Cloud Native Event Mesh: ![architecture2](../images/eventmesh-panels.png) -The event mesh allows events from one application to be dynamically routed to any other application. -General functions of the event mesh: +The event mesh allows events from one application to be dynamically routed to any other application. General functions +of the event mesh: * Event driven; * Event governance; @@ -27,14 +30,19 @@ General functions of the event mesh: * Cloud native Dependent components: -* DeFiBus : a distributed messaging platform with low latency, high performance and reliability, flexible scalability. [DeFiBus](https://github.com/WeBankFinTech/DeFiBus) + +* DeFiBus : a distributed messaging platform with low latency, high performance and reliability, flexible + scalability. [DeFiBus](https://github.com/WeBankFinTech/DeFiBus) * RocketMQ Key components: -* eventmesh-runtime : an middleware to transmit events between event producers and consumers, support cloud native apps and microservices + +* 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, and will support gRPC in the future ## RoadMap + | version | feature | | ---- | ---- | | v1.0.0 |Support DeFiBus as eventstore, support pub/sub, http api, java-sdk| @@ -54,21 +62,27 @@ Key components: | |Support c/go/python/nodejs SDK| ## Quick Start -1. Build and deploy event-store([DeFiBus](https://github.com/WeBankFinTech/DeFiBus)), - see instruction ['event-store quickstart'](instructions/eventmesh-store-quickstart.md). -2. Build and deploy eventmesh-runtime, see instruction ['eventmesh-runtime quickstart'](instructions/eventmesh-runtime-quickstart.md). -3. Run eventmesh-sdk-java demo, see instruction ['eventmesh-sdk-java quickstart'](instructions/eventmesh-sdk-java-quickstart.md). + +1. Build and deploy event-store([DeFiBus](https://github.com/WeBankFinTech/DeFiBus)), see + instruction ['event-store quickstart'](instructions/eventmesh-store-quickstart.md). +2. Build and deploy eventmesh-runtime, see + instruction ['eventmesh-runtime quickstart'](instructions/eventmesh-runtime-quickstart.md). +3. Run eventmesh-sdk-java demo, see + instruction ['eventmesh-sdk-java quickstart'](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/WeBankFinTech/EventMesh/issues) +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) ## License + [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation ## Contacts + WeChat group: ![wechat_qr](../images/mesh-helper.png) diff --git a/docs/en/features/architecture.md b/docs/en/features/architecture.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/docs/en/features/https.md b/docs/en/features/https.md index f78c8c80a8..247853960f 100644 --- a/docs/en/features/https.md +++ b/docs/en/features/https.md @@ -12,8 +12,8 @@ config env varible ``` +2.config in eventmesh-sdk-java -2.config in eventmesh-sdk-java ``` // create producer LiteClientConfig liteClientConfig = new liteClientConfig(); diff --git a/docs/en/features/request-response-call.md b/docs/en/features/request-response-call.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/docs/en/instructions/eventmesh-runtime-protocol.md b/docs/en/instructions/eventmesh-runtime-protocol.md index c2f22ee22f..a884a49193 100644 --- a/docs/en/instructions/eventmesh-runtime-protocol.md +++ b/docs/en/instructions/eventmesh-runtime-protocol.md @@ -20,8 +20,6 @@ Message Header: the specific header content of message Message Body: the specific body content of message ``` - - #### 2. Message Object in business logic layer * Message Composition @@ -45,13 +43,11 @@ public class Header { } ``` - - * Specificatiion -Message Header(header): The field of Command in Header, used to distinguishing different message types. +Message Header(header): The field of Command in Header, used to distinguishing different message types. -Message Body(body): The message body is defined as different objects according to the message type. +Message Body(body): The message body is defined as different objects according to the message type. | Command | type of Body | | ------------------------------------------------------------ | ------------ | @@ -61,8 +57,6 @@ Message Body(body): The message body is defined as different objects according t | REQUEST_TO_SERVER, REQUEST_TO_CLIENT, RESPONSE_TO_SERVER, RESPONSE_TO_CLIENT, ASYNC_MESSAGE_TO_SERVER, ASYNC_MESSAGE_TO_CLIENT, BROADCAST_MESSAGE_TO_SERVER, BROADCAST_MESSAGE_TO_CLIENT, ASYNC_MESSAGE_TO_CLIENT_ACK, BROADCAST_MESSAGE_TO_CLIENT_ACK, RESPONSE_TO_CLIENT_ACK, REQUEST_TO_CLIENT_ACK | OpenMessage | | REDIRECT_TO_CLIENT | RedirectInfo | - - #### 3. The Interactive Command between Client and Server(Eventmesh-Runtime) ```java @@ -117,8 +111,6 @@ public enum Command { } ``` - - #### 4. Client initiates interaction | Scene | Client Send | Server Reply | Remark | @@ -134,8 +126,6 @@ public enum Command { | Send broadcast msg | BROADCAST_MESSAGE_TO_SERVER | BROADCAST_MESSAGE_TO_SERVER_ACK | | | Client start disconnect | CLIENT_GOODBYE_REQUEST | CLIENT_GOODBYE_RESPONSE | | - - #### 5. Server initiates interaction | Scene | Server Send | Client Reply | Remark | @@ -147,30 +137,25 @@ public enum Command { | Server start disconnect | SERVER_GOODBYE_REQUEST | -- | | | Server send redirect | REDIRECT_TO_CLIENT | -- | | - #### 6. Message classification + Send sync msg ![rr-msg](../../images/protocol/eventmesh-rr-msg.png) - - + Send async msg ![async-msg](../../images/protocol/eventmesh-async-msg.png) - - + Send broadcast msg ![broadcast-msg](../../images/protocol/eventmesh-broadcast-msg.png) - - ## HTTP Protocol Document In Eventmesh-Runtime -The class of `LiteMessage.java` is message definition in http protocal of EventMesh-Runtime.If you want to send msg by using http protocol,you can use client in eventmesh-sdk-java, and you just need care the specific protocol in the field of content. +The class of `LiteMessage.java` is message definition in http protocal of EventMesh-Runtime.If you want to send msg by +using http protocol,you can use client in eventmesh-sdk-java, and you just need care the specific protocol in the field +of content. ```java public class LiteMessage { @@ -189,17 +174,12 @@ public class LiteMessage { } ``` - - #### 1. Message Send and Message Composition - **Request Method**: POST **Message Composition**: RequestHeader + RequestBody - - + Heartbeat Msg **RequestHeader** @@ -226,8 +206,6 @@ public class LiteMessage { | clientType | Producer:clientType is ClientType.PUB,Consumer:clientType is ClientType.SUB | | heartbeatEntities | Heartbeat content,contains topic,url... | - - + Subscribe Msg **RequestHeader** @@ -241,8 +219,6 @@ same with RequestHeader of heartbeat msg | topic | topic of client want to subscribe | | url | url of client, server push msg to the url when receiving msg from other components | - - + Unsubscribe Msg **RequestHeader** @@ -253,8 +229,6 @@ same with RequestHeader of Heartbeat Msg same with RequestBody of Subscribe Msg - - + Send async msg **RequestHeader** @@ -271,8 +245,6 @@ same with RequestHeader of Heartbeat Msg | bizSeqNo | biz sequence number of msg | | uniqueId | unique mark of msg | - - #### 2. Client initiates interaction | Scene | Client Send | Server Reply | Remark | @@ -282,8 +254,6 @@ same with RequestHeader of Heartbeat Msg | Unsubscribe | UNSUBSCRIBE(207) | SUCCESS(0)/EVENTMESH_UNSUBSCRIBE_ERROR(18) | | | Send async msg | MSG_SEND_ASYNC(104) | SUCCESS(0)/EVENTMESH_SEND_ASYNC_MSG_ERR(14) | | - - #### 3. Server initiates interaction | Scene | Server Send | Client Reply | Remark | diff --git a/docs/en/instructions/eventmesh-runtime-quickstart.md b/docs/en/instructions/eventmesh-runtime-quickstart.md index b35f63086f..0536e5b6ee 100644 --- a/docs/en/instructions/eventmesh-runtime-quickstart.md +++ b/docs/en/instructions/eventmesh-runtime-quickstart.md @@ -7,27 +7,27 @@ ``` 64bit OS, Linux/Unix is recommended; 64bit JDK 1.8+; -Gradle at least 5.6, eg 5.6.* +Gradle at least 7.0, eg 7.0.* ``` ### 1.2 download sources -download source code from [https://github.com/WeBankFinTech/EventMesh](https://github.com/WeBankFinTech/EventMesh) +download source code from [https://github.com/apache/incubator-eventmesh](https://github.com/apache/incubator-eventmesh) You will get **EventMesh-master.zip** ### 1.3 build sources ```$xslt unzip EventMesh-master.zip -cd /*YOUR DEPLOY PATH*/EventMesh-master/eventmesh-runtime -gradle clean tar -x test +cd /*YOUR DEPLOY PATH*/EventMesh-master +gradle clean dist tar -x test ``` You will get **EventMesh_1.2.0.tar.gz** in directory /* YOUR DEPLOY PATH */EventMesh-master/build ### 1.4 Deployment -- deploy eventmesh-runtime +- deploy eventmesh-runtime ```shell upload Eventmesh_1.2.0.tar.gz @@ -40,8 +40,6 @@ sh start.sh If you see "EventMeshTCPServer[port=10000] started....", you setup runtime successfully. - - ## 2 Run Locally ### 2.1 dependencies @@ -65,16 +63,18 @@ Same with 1.2 - eventmesh-sdk-java : eventmesh java client sdk - eventmesh-starter : eventmesh project local start entry -ps:The loading of connector plugin follows the Java SPI mechanism, it's necessary to configure the mapping file of related interface and implementation class under /main/resources/meta-inf/services in the corresponding module +> ps: The loading of connector plugin follows the Java SPI mechanism, it's necessary to configure the mapping file of +related interface and implementation class under /main/resources/meta-inf/services in the corresponding module **2.3.2 Configure VM Options** ```java --Dlog4j.configurationFile=..\eventmesh-runtime\conf\log4j2.xml --Deventmesh.log.home=..\eventmesh-runtime\logs --Deventmesh.home=..\eventmesh-runtime --DconfPath=..\eventmesh-runtime\conf +-Dlog4j.configurationFile=eventmesh-runtime/conf/log4j2.xml +-Deventmesh.log.home=eventmesh-runtime/logs +-Deventmesh.home=eventmesh-runtime +-DconfPath=eventmesh-runtime/conf ``` +> ps: If you use Windows, you may need to replace the file separator to \ **2.3.3 Configure build.gradle file** @@ -92,11 +92,9 @@ dependencies { **2.3.4 Run** -running `com.webank.eventmesh.starter.StartUp` main method - - +running `org.apache.eventmesh.starter.StartUp` main method -## 3 Run with Docker +## 3 Run with Docker ### 3.1 Pull @@ -112,7 +110,7 @@ execute `docker pull eventmesh/eventmesh-rocketmq:v1.2.0` , you will get EventMe Before run the container you should configure some files. -**eventMesh.properties** +**eventMesh.properties** | Configuration Key | Default Value | Remarks | | ---------------------- | ------------- | -------------------------- | @@ -125,7 +123,8 @@ Before run the container you should configure some files. | --------------------------------- | ----------------------------- | -------------------------------- | | eventMesh.server.rocketmq.namesrvAddr | 127.0.0.1:9876;127.0.0.1:9876 | RocketMQ namesrv default address | -After pull the EventMesh image to your host machine, you can execute command below to configure **eventMesh.properties** and **rocketmq-client.properties** +After pull the EventMesh image to your host machine, you can execute command below to configure **eventMesh.properties** +and **rocketmq-client.properties** **3.2.2 Create Files** @@ -136,7 +135,9 @@ vi eventMesh.properties vi rocketmq-client.properties ``` -The contents of these files can reference from [eventMesh.properties](https://github.com/WeBankFinTech/EventMesh/blob/develop/eventmesh-runtime/conf/eventMesh.properties) and [rocketmq-client.properties](https://github.com/WeBankFinTech/EventMesh/blob/develop/eventmesh-runtime/conf/rocketmq-client.properties) +The contents of these files can reference +from [eventMesh.properties](https://github.com/WeBankFinTech/EventMesh/blob/develop/eventmesh-runtime/conf/eventMesh.properties) +and [rocketmq-client.properties](https://github.com/WeBankFinTech/EventMesh/blob/develop/eventmesh-runtime/conf/rocketmq-client.properties) ### 3.3 Run @@ -170,7 +171,8 @@ execute `docker exec -it [container id] /bin/bash` you will go into the containe **Prerequisite** :RocketMQ Namesrv & Broker -you can build the rocketmq image following [here](https://github.com/apache/rocketmq-docker) or get the rocketmq image from docker hub. +you can build the rocketmq image following [here](https://github.com/apache/rocketmq-docker) or get the rocketmq image +from docker hub. ``` docker pull rocketmqinc/rocketmq-namesrv:4.5.0-alpine @@ -183,13 +185,15 @@ docker run -d -p 9876:9876 -v `pwd` /data/namesrv/logs:/root/logs -v `pwd`/data/ docker run -d -p 10911:10911 -p 10909:10909 -v `pwd`/data/broker/logs:/root/logs -v `pwd`/data/broker/store:/root/store --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" rocketmqinc/rocketmq-broker:4.5.0-alpine sh mqbroker -c ../conf/broker.conf ``` -When we get this point, **rocketmq-broker ip** is the **pod ip**, if you want to change the ip, you can mount the **broker.conf** file in container and modify **brokerIP1** configuration in this file to your custom values. +When we get this point, **rocketmq-broker ip** is the **pod ip**, if you want to change the ip, you can mount the ** +broker.conf** file in container and modify **brokerIP1** configuration in this file to your custom values. **3.4.1 Run Demo** Windows -- For demos running under the Windows , you can refer [here](https://github.com/WeBankFinTech/EventMesh/blob/develop/docs/en/instructions/eventmesh-sdk-java-quickstart.md) +- For demos running under the Windows , you can + refer [here](https://github.com/WeBankFinTech/EventMesh/blob/develop/docs/en/instructions/eventmesh-sdk-java-quickstart.md) Linux @@ -204,7 +208,7 @@ Linux gradle clean testdist testtar -x test` ``` - you will get **eventmesh-test_1.2.0-SNAPSHOT.tar.gz** under the /eventmesh-test/build + you will get **eventmesh-test_1.2.0-SNAPSHOT.tar.gz** under the /eventmesh-test/build - **Modify configuration files** @@ -217,7 +221,7 @@ Linux - **Run demo** - TCP Sub + TCP Sub ```shell cd bin diff --git a/docs/en/instructions/eventmesh-sdk-java-quickstart.md b/docs/en/instructions/eventmesh-sdk-java-quickstart.md index 394a44d68f..a754502aa8 100644 --- a/docs/en/instructions/eventmesh-sdk-java-quickstart.md +++ b/docs/en/instructions/eventmesh-sdk-java-quickstart.md @@ -1,55 +1,55 @@ ## How to run eventmesh-sdk-java demo -> Eventmesh-sdk-java , as the client, communicated with eventmesh-runtime, used to complete the sending and receiving of message. +> Eventmesh-sdk-java , as the client, communicated with eventmesh-runtime, used to complete the sending and receiving of message. > -> Eventmesh-sdk-java supports async msg and broadcast msg. Async msg means the producer just sends msg and does not care reply msg.Broadcast msg means the producer send msg once and all the consumer subscribed the broadcast topic will receive the msg. +> Eventmesh-sdk-java supports async msg and broadcast msg. Async msg means the producer just sends msg and does not care reply msg.Broadcast msg means the producer send msg once and all the consumer subscribed the broadcast topic will receive the msg. > -> Eventmesh-sdk-java supports the protocol of HTTP and TCP. +> Eventmesh-sdk-java supports the protocol of HTTP and TCP. TCP demos and Http demos are both under the **eventmesh-test** module. -**prerequisite**:after download the source code you should copy `/conf/application.properties` and `/conf/log4j2.xml` to the `resources` directory +**prerequisite**:after download the source code you should copy `/conf/application.properties` and `/conf/log4j2.xml` to +the `resources` directory ![image-test-structure](../../images/eventmesh-test-structure.png) -### 1. TCP DEMO +### 1. TCP DEMO -#### Async msg +#### Async msg - create topic FT0-e-80010000-01-1 on rocketmq-console -- start consumer ,subscribe topic in previous step. +- start consumer ,subscribe topic in previous step. ``` -Run the main method of com.webank.eventmesh.tcp.demo.AsyncSubscribe +Run the main method of org.apache.eventmesh.tcp.demo.AsyncSubscribe ``` -- start producer, send message - +- start producer, send message ``` -Run the main method of com.webank.eventmesh.tcp.demo.AsyncPublish +Run the main method of org.apache.eventmesh.tcp.demo.AsyncPublish ``` -#### Broadcast msg +#### Broadcast msg - create topic FT0-e-80030000-01-3 on rocketmq-console -- start consumer ,subscribe topic in previous step. +- start consumer ,subscribe topic in previous step. ``` -Run the main method of com.webank.eventmesh.tcp.demo.AsyncSubscribeBroadcast +Run the main method of org.apache.eventmesh.tcp.demo.AsyncSubscribeBroadcast ``` * start producer, send broadcast message ``` -Run the main method of com.webank.eventmesh.tcp.demo.AsyncPublishBroadcast +Run the main method of org.apache.eventmesh.tcp.demo.AsyncPublishBroadcast ``` ### 2. HTTP DEMO -> As to http, eventmesh-sdk-java implements the pub and sub for async event . +> As to http, eventmesh-sdk-java implements the pub and sub for async event . > > In the demo ,the field of `content` of the java class `LiteMessage` represents a special protocal, so if you want to use http-client of eventmesh-sdk-java, you just need to design the content of protocal and supply the consumer appliacation at the same time. @@ -61,15 +61,16 @@ Run the main method of com.webank.eventmesh.tcp.demo.AsyncPublishBroadcast - start consumer, subscribe topic - Async consumer demo is a spring boot application demo, you can easily run this demo to start service and subscribe the topic. + Async consumer demo is a spring boot application demo, you can easily run this demo to start service and subscribe the + topic. ``` -Run the main method of com.webank.eventmesh.http.demo.sub.SpringBootDemoApplication +Run the main method of org.apache.eventmesh.http.demo.sub.SpringBootDemoApplication ``` - start producer, produce msg ``` -Run the main method of com.webank.eventmesh.http.demo.AsyncPublishInstance +Run the main method of org.apache.eventmesh.http.demo.AsyncPublishInstance ``` diff --git a/docs/en/instructions/eventmesh-store-quickstart.md b/docs/en/instructions/eventmesh-store-quickstart.md index 8ba16d99aa..74158e85fc 100644 --- a/docs/en/instructions/eventmesh-store-quickstart.md +++ b/docs/en/instructions/eventmesh-store-quickstart.md @@ -1,6 +1,7 @@ # Eventmesh-store Quick start Instruction ### dependencies + ``` 64bit OS, Linux/Unix is recommended; 64bit JDK 1.8+; @@ -9,29 +10,38 @@ Gradle at least 5.6, eg 5.6.* ``` ### download sources + download source code from [https://github.com/WeBankFinTech/DeFiBus](https://github.com/WeBankFinTech/DeFiBus) You will get **DefiBus-master.zip** ### build sources -The eventmesh-store takes DeFiBus for example at the follwing parts, because eventmesh depends on defibus as store layer by default, other implements such as Rocketmq etc. is coming soon. + +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 + +- 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 @@ -40,6 +50,7 @@ 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. + +If you see "The broker \[YOUR-BROKER-NAME, IP:PORT\] boot success." in ../logs/broker.log, you setup eventmesh-store +successfully. diff --git a/docs/en/instructions/quickstart.md b/docs/en/instructions/quickstart.md index cd5de96a29..697dd7c5e4 100644 --- a/docs/en/instructions/quickstart.md +++ b/docs/en/instructions/quickstart.md @@ -1,6 +1,7 @@ # Quick start Instruction ### dependencies + ``` 64bit OS, Linux/Unix is recommended; 64bit JDK 1.8+; @@ -8,10 +9,13 @@ Gradle at least 5.6, eg 5.6.* ``` ### Deploy eventmesh-store + Read more [here](eventmesh-store-quickstart.md) ### Deploy eventmesh-runtime + Read more [here](eventmesh-runtime-quickstart.md) ### Run eventmesh sdk demo + Read more [here](eventmesh-sdk-java-quickstart.md) \ No newline at end of file diff --git a/docs/eventmesh.md b/docs/eventmesh.md index e39cba6546..432c09360d 100644 --- a/docs/eventmesh.md +++ b/docs/eventmesh.md @@ -1,4 +1,5 @@ ## 什么是Event Mesh? + EventMesh是一个动态的云原生事件驱动架构基础设施,用于分离应用程序和后端中间件层,它支持广泛的用例,包括复杂的混合云、使用了不同技术栈的分布式架构。 ![architecture1](images/eventmesh-define.png) @@ -10,8 +11,7 @@ EventMesh是一个动态的云原生事件驱动架构基础设施,用于分 ![architecture2](images/eventmesh-panels.png) -EventMesh允许将来自一个应用程序的事件动态路由到任何其他应用程序. -EventMesh的一般功能: +EventMesh允许将来自一个应用程序的事件动态路由到任何其他应用程序. EventMesh的一般功能: * 事件驱动; * 事件治理; @@ -19,16 +19,18 @@ EventMesh的一般功能: * 云原生; 依赖部件: + * [RocketMQ](https://github.com/apache/rocketmq):RocketMQ是一个分布式消息流平台,具有低延迟、高性能和可靠性、万亿级容量和灵活的可伸缩性。 关键部件: + * eventmesh-runtime:一种中间件,用于在事件产生者和使用者之间传输事件,支持云原生应用程序和微服务 * eventmesh-sdk-java:当前支持HTTP和TCP协议,未来会支持gRPC等 - ## 开源地址 + * https://github.com/WeBankFinTech/DeFiBus -* https://github.com/WeBankFinTech/EventMesh +* https://github.com/apache/incubator-eventmesh * https://gitee.com/WeBank/DeFiBus * https://gitee.com/WeBank/EventMesh diff --git a/docs/images/eventmesh-multi-runtime.png b/docs/images/eventmesh-multi-runtime.png new file mode 100644 index 0000000000..a9b90be778 Binary files /dev/null and b/docs/images/eventmesh-multi-runtime.png differ diff --git a/eventmesh-common/build.gradle b/eventmesh-common/build.gradle index 9de9a20847..d973dcedae 100644 --- a/eventmesh-common/build.gradle +++ b/eventmesh-common/build.gradle @@ -13,79 +13,4 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ - -apply plugin: 'java' -apply plugin: "maven" -apply plugin: "eclipse" -apply plugin: "idea" - -if (project.findProperty("jdk") == "1.7") { - sourceCompatibility = 1.7 - targetCompatibility = 1.7 -} else { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - version = version + "-jdk8" -} - -if (project.findProperty("snapshot") instanceof String) { - if (project.property("snapshot").toBoolean()) version = version + "-SNAPSHOT" -} - -repositories { - mavenLocal() - maven { - url "https://maven.aliyun.com/repository/public" - } - mavenCentral() -} - -List fastjson = [ - "com.alibaba:fastjson:1.2.71" -] - -List jackson = [ - 'com.fasterxml.jackson.core:jackson-databind:2.11.0', - 'com.fasterxml.jackson.core:jackson-core:2.11.0', - 'com.fasterxml.jackson.core:jackson-annotations:2.11.0' -] - -List apache_commons = [ - "org.apache.commons:commons-lang3:3.6", - "org.apache.commons:commons-collections4:4.1" -] - -List httpclient = [ - "org.apache.httpcomponents:httpclient:4.5.2" -] - -List guava = [ - "com.google.guava:guava:29.0-jre" -] - -List netty = [ - "io.netty:netty-all:4.1.49.Final" -] - -dependencies { - compile apache_commons, httpclient, guava, netty, fastjson, jackson - testCompile apache_commons, httpclient, guava, netty, fastjson, jackson -} - -uploadArchives { - repositories { - mavenDeployer { - snapshotRepository(url: 'Your target repo address') { - authentication(userName: 'Your user name', password: 'Your password') - } - repository(url: 'Your target repo address') { - authentication(userName: 'Your user name', password: 'Your password') - } - } - } -} - -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" -} \ No newline at end of file + */ \ No newline at end of file diff --git a/eventmesh-common/gradle.properties b/eventmesh-common/gradle.properties index bca7b2e0a4..b4202ce825 100644 --- a/eventmesh-common/gradle.properties +++ b/eventmesh-common/gradle.properties @@ -14,8 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - -group=com.webank.eventmesh +group=org.apache.eventmesh version=1.2.0-SNAPSHOT -defibus_version=1.0.1 jdk=1.7 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/Constants.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/Constants.java similarity index 98% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/Constants.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/Constants.java index 97ee4bc001..937859a8b4 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/Constants.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/Constants.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common; +package org.apache.eventmesh.common; public class Constants { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/EventMeshException.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshException.java similarity index 97% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/EventMeshException.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshException.java index b20fcbba25..bffa57e780 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/EventMeshException.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshException.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common; +package org.apache.eventmesh.common; public class EventMeshException extends Exception { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/IPUtil.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/IPUtil.java similarity index 98% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/IPUtil.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/IPUtil.java index e0b7826b64..4cd19e4f3b 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/IPUtil.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/IPUtil.java @@ -15,9 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common; - -import io.netty.channel.Channel; +package org.apache.eventmesh.common; import java.net.Inet6Address; import java.net.InetAddress; @@ -30,6 +28,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import io.netty.channel.Channel; + public class IPUtil { public static String getLocalAddress() { @@ -107,8 +107,7 @@ else if (preferList.indexOf(networkInterface.getName()) return null; } - public static boolean isValidIPV4Address(String ip) - { + public static boolean isValidIPV4Address(String ip) { // Regex for digit from 0 to 255. String zeroTo255 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/LiteMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/LiteMessage.java similarity index 98% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/LiteMessage.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/LiteMessage.java index e0d9666bf7..455dfc65d0 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/LiteMessage.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/LiteMessage.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package com.webank.eventmesh.common; - -import org.apache.commons.lang3.time.DateFormatUtils; +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; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/ThreadPoolFactory.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java similarity index 99% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/ThreadPoolFactory.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java index c8e5f85e56..5be65297b3 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/ThreadPoolFactory.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common; +package org.apache.eventmesh.common; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Executors; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/ThreadUtil.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadUtil.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/ThreadUtil.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadUtil.java index 3a25b806b3..aecfb0e3d0 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/ThreadUtil.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadUtil.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package com.webank.eventmesh.common; +package org.apache.eventmesh.common; import java.util.concurrent.ThreadLocalRandom; public class ThreadUtil { - private static long currentPID=-1; + private static 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 @@ -36,6 +36,7 @@ public static void randomSleep(int max) throws Exception { /** * get current process id only once. + * * @return */ public static long getPID() { @@ -45,7 +46,7 @@ public static long getPID() { String processName = java.lang.management.ManagementFactory.getRuntimeMXBean().getName(); if (processName != null && processName.length() > 0) { try { - currentPID= Long.parseLong(processName.split("@")[0]); + currentPID = Long.parseLong(processName.split("@")[0]); } catch (Exception e) { return 0; } diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/command/HttpCommand.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/command/HttpCommand.java similarity index 94% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/command/HttpCommand.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/command/HttpCommand.java index 4ac40a0b99..31179562af 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/command/HttpCommand.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/command/HttpCommand.java @@ -15,14 +15,13 @@ * limitations under the License. */ -package com.webank.eventmesh.common.command; +package org.apache.eventmesh.common.command; + +import java.util.Map; +import java.util.concurrent.atomic.AtomicLong; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.body.BaseResponseBody; -import com.webank.eventmesh.common.protocol.http.body.Body; -import com.webank.eventmesh.common.protocol.http.header.BaseResponseHeader; -import com.webank.eventmesh.common.protocol.http.header.Header; import com.alibaba.fastjson.JSON; + import io.netty.buffer.Unpooled; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.HttpHeaderNames; @@ -30,11 +29,14 @@ import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpVersion; + import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicLong; +import org.apache.eventmesh.common.Constants; +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.BaseResponseHeader; +import org.apache.eventmesh.common.protocol.http.header.Header; public class HttpCommand { @@ -75,7 +77,7 @@ public HttpCommand(String httpMethod, String httpVersion, String requestCode) { public HttpCommand createHttpCommandResponse(Header header, Body body) { - if(StringUtils.isBlank(requestCode)) { + if (StringUtils.isBlank(requestCode)) { return null; } HttpCommand response = new HttpCommand(this.httpMethod, this.httpVersion, this.requestCode); @@ -89,7 +91,7 @@ public HttpCommand createHttpCommandResponse(Header header, } public HttpCommand createHttpCommandResponse(Integer retCode, String retMsg) { - if(StringUtils.isBlank(requestCode)) { + if (StringUtils.isBlank(requestCode)) { return null; } HttpCommand response = new HttpCommand(this.httpMethod, this.httpVersion, this.requestCode); diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/config/CommonConfiguration.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java similarity index 72% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/config/CommonConfiguration.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java index 0a568af0b0..931f41bf99 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/config/CommonConfiguration.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java @@ -15,15 +15,20 @@ * limitations under the License. */ -package com.webank.eventmesh.common.config; +package org.apache.eventmesh.common.config; -import com.google.common.base.Preconditions; -import org.apache.commons.lang3.StringUtils; - -import java.net.*; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Enumeration; +import com.google.common.base.Preconditions; + +import org.apache.commons.lang3.StringUtils; + public class CommonConfiguration { public String eventMeshEnv = "P"; public String eventMeshRegion = ""; @@ -57,37 +62,40 @@ public CommonConfiguration(ConfigurationWraper configurationWraper) { } public void init() { - String eventMeshEnvStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ENV); - Preconditions.checkState(StringUtils.isNotEmpty(eventMeshEnvStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ENV)); - eventMeshEnv = StringUtils.deleteWhitespace(eventMeshEnvStr); - String eventMeshRegionStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_REGION); - Preconditions.checkState(StringUtils.isNotEmpty(eventMeshRegionStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_REGION)); - eventMeshRegion = StringUtils.deleteWhitespace(eventMeshRegionStr); + if (configurationWraper != null) { + String eventMeshEnvStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ENV); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshEnvStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ENV)); + eventMeshEnv = StringUtils.deleteWhitespace(eventMeshEnvStr); - String sysIdStr = configurationWraper.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 eventMeshRegionStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_REGION); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshRegionStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_REGION)); + eventMeshRegion = StringUtils.deleteWhitespace(eventMeshRegionStr); - String eventMeshClusterStr = configurationWraper.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 sysIdStr = configurationWraper.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 eventMeshNameStr = configurationWraper.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 eventMeshClusterStr = configurationWraper.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 eventMeshIDCStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_IDC); - Preconditions.checkState(StringUtils.isNotEmpty(eventMeshIDCStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_IDC)); - eventMeshIDC = StringUtils.deleteWhitespace(eventMeshIDCStr); + String eventMeshNameStr = configurationWraper.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 eventMeshDCNStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DCN); - Preconditions.checkState(StringUtils.isNotEmpty(eventMeshDCNStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DCN)); - eventMeshDCN = StringUtils.deleteWhitespace(eventMeshDCNStr); + String eventMeshIDCStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_IDC); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshIDCStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_IDC)); + eventMeshIDC = StringUtils.deleteWhitespace(eventMeshIDCStr); - eventMeshServerIp = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_HOST_IP); - if(StringUtils.isBlank(eventMeshServerIp)) { - eventMeshServerIp = getLocalAddr(); + String eventMeshDCNStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DCN); + Preconditions.checkState(StringUtils.isNotEmpty(eventMeshDCNStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DCN)); + eventMeshDCN = StringUtils.deleteWhitespace(eventMeshDCNStr); + + eventMeshServerIp = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_HOST_IP); + if (StringUtils.isBlank(eventMeshServerIp)) { + eventMeshServerIp = getLocalAddr(); + } } } diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/config/ConfigurationWraper.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/ConfigurationWraper.java similarity index 96% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/config/ConfigurationWraper.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/config/ConfigurationWraper.java index 21ded1f3bb..2da975b394 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/config/ConfigurationWraper.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/ConfigurationWraper.java @@ -15,12 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.config; - -import com.webank.eventmesh.common.ThreadPoolFactory; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.common.config; import java.io.BufferedReader; import java.io.File; @@ -30,6 +25,11 @@ 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; + public class ConfigurationWraper { public Logger logger = LoggerFactory.getLogger(this.getClass()); diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/BaseRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/BaseRequestBody.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/BaseRequestBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/BaseRequestBody.java index 23107ffe08..09a3f741a0 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/BaseRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/BaseRequestBody.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body; +package org.apache.eventmesh.common.protocol.http.body; import java.util.HashMap; import java.util.Map; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/BaseResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/BaseResponseBody.java similarity index 93% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/BaseResponseBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/BaseResponseBody.java index 4f17ffe57a..5cb5922f19 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/BaseResponseBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/BaseResponseBody.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body; +package org.apache.eventmesh.common.protocol.http.body; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; - import java.util.HashMap; import java.util.Map; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; + public class BaseResponseBody extends Body { private Integer retCode; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/Body.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/Body.java similarity index 77% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/Body.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/Body.java index 65dce6a7ad..c6976433d8 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/Body.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/Body.java @@ -15,19 +15,23 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body; +package org.apache.eventmesh.common.protocol.http.body; -import com.webank.eventmesh.common.protocol.http.body.client.*; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; -import com.webank.eventmesh.common.protocol.http.body.message.ReplyMessageRequestBody; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageBatchRequestBody; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageBatchV2RequestBody; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; - import java.util.Map; +import org.apache.eventmesh.common.protocol.http.body.client.HeartbeatRequestBody; +import org.apache.eventmesh.common.protocol.http.body.client.RegRequestBody; +import org.apache.eventmesh.common.protocol.http.body.client.SubscribeRequestBody; +import org.apache.eventmesh.common.protocol.http.body.client.UnRegRequestBody; +import org.apache.eventmesh.common.protocol.http.body.client.UnSubscribeRequestBody; +import org.apache.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; +import org.apache.eventmesh.common.protocol.http.body.message.ReplyMessageRequestBody; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchRequestBody; +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.RequestCode; + public abstract class Body { public abstract Map toMap(); @@ -35,7 +39,8 @@ public abstract class Body { public static Body buildBody(String requestCode, Map originalMap) throws Exception { if (String.valueOf(RequestCode.MSG_BATCH_SEND.getRequestCode()).equals(requestCode)) { return SendMessageBatchRequestBody.buildBody(originalMap); - } if (String.valueOf(RequestCode.MSG_BATCH_SEND_V2.getRequestCode()).equals(requestCode)) { + } + if (String.valueOf(RequestCode.MSG_BATCH_SEND_V2.getRequestCode()).equals(requestCode)) { return SendMessageBatchV2RequestBody.buildBody(originalMap); } else if (String.valueOf(RequestCode.MSG_SEND_ASYNC.getRequestCode()).equals(requestCode)) { return SendMessageRequestBody.buildBody(originalMap); diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/HeartbeatRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/HeartbeatRequestBody.java similarity index 96% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/HeartbeatRequestBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/HeartbeatRequestBody.java index 4a273c2eb6..5c3d1ea09e 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/HeartbeatRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/HeartbeatRequestBody.java @@ -15,17 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.client; - -import com.webank.eventmesh.common.protocol.http.body.Body; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import org.apache.commons.collections4.MapUtils; +package org.apache.eventmesh.common.protocol.http.body.client; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; + +import org.apache.commons.collections4.MapUtils; +import org.apache.eventmesh.common.protocol.http.body.Body; + public class HeartbeatRequestBody extends Body { public static final String CLIENTTYPE = "clientType"; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/HeartbeatResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/HeartbeatResponseBody.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/HeartbeatResponseBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/HeartbeatResponseBody.java index fd49b5df8c..0f05f512ce 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/HeartbeatResponseBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/HeartbeatResponseBody.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.client; - -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.body.Body; -import org.apache.commons.lang3.time.DateFormatUtils; +package org.apache.eventmesh.common.protocol.http.body.client; 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; + public class HeartbeatResponseBody extends Body { //响应码 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/RegRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/RegRequestBody.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/RegRequestBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/RegRequestBody.java index 8739590bf6..41c5c5ab98 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/RegRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/RegRequestBody.java @@ -15,17 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.client; - -import com.webank.eventmesh.common.protocol.http.body.Body; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import org.apache.commons.collections4.MapUtils; +package org.apache.eventmesh.common.protocol.http.body.client; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; + +import org.apache.commons.collections4.MapUtils; +import org.apache.eventmesh.common.protocol.http.body.Body; + public class RegRequestBody extends Body { public static final String CLIENTTYPE = "clientType"; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/RegResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/RegResponseBody.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/RegResponseBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/RegResponseBody.java index cffd492eb6..1fc1366f31 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/RegResponseBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/RegResponseBody.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.client; - -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.body.Body; -import org.apache.commons.lang3.time.DateFormatUtils; +package org.apache.eventmesh.common.protocol.http.body.client; 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; + public class RegResponseBody extends Body { private Integer retCode; private String retMsg; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/SubscribeRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/SubscribeRequestBody.java similarity index 94% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/SubscribeRequestBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/SubscribeRequestBody.java index c7c4ea2bdd..6a37cc53d2 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/SubscribeRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/SubscribeRequestBody.java @@ -15,17 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.client; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.webank.eventmesh.common.protocol.http.body.Body; -import org.apache.commons.collections4.MapUtils; +package org.apache.eventmesh.common.protocol.http.body.client; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; + +import org.apache.commons.collections4.MapUtils; +import org.apache.eventmesh.common.protocol.http.body.Body; + public class SubscribeRequestBody extends Body { public static final String TOPIC = "topic"; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/SubscribeResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/SubscribeResponseBody.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/SubscribeResponseBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/SubscribeResponseBody.java index 40d94dd16e..21b70826cd 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/SubscribeResponseBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/SubscribeResponseBody.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.client; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.body.Body; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import org.apache.commons.lang3.time.DateFormatUtils; +package org.apache.eventmesh.common.protocol.http.body.client; 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; + public class SubscribeResponseBody extends Body { private Integer retCode; private String retMsg; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/UnRegRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/UnRegRequestBody.java similarity index 96% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/UnRegRequestBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/UnRegRequestBody.java index f0e0b7c111..fe445957f2 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/UnRegRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/UnRegRequestBody.java @@ -15,17 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.client; - -import com.webank.eventmesh.common.protocol.http.body.Body; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import org.apache.commons.collections4.MapUtils; +package org.apache.eventmesh.common.protocol.http.body.client; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; + +import org.apache.commons.collections4.MapUtils; +import org.apache.eventmesh.common.protocol.http.body.Body; + public class UnRegRequestBody extends Body { public static final String CLIENTTYPE = "clientType"; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/UnRegResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/UnRegResponseBody.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/UnRegResponseBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/UnRegResponseBody.java index b4118dd7e3..325095187e 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/UnRegResponseBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/UnRegResponseBody.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.client; - -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.body.Body; -import org.apache.commons.lang3.time.DateFormatUtils; +package org.apache.eventmesh.common.protocol.http.body.client; 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; + public class UnRegResponseBody extends Body { private Integer retCode; private String retMsg; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/UnSubscribeRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/UnSubscribeRequestBody.java similarity index 94% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/UnSubscribeRequestBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/UnSubscribeRequestBody.java index 9fc03e3279..e690f7e599 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/UnSubscribeRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/UnSubscribeRequestBody.java @@ -15,17 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.client; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.webank.eventmesh.common.protocol.http.body.Body; -import org.apache.commons.collections4.MapUtils; +package org.apache.eventmesh.common.protocol.http.body.client; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; + +import org.apache.commons.collections4.MapUtils; +import org.apache.eventmesh.common.protocol.http.body.Body; + public class UnSubscribeRequestBody extends Body { public static final String TOPIC = "topic"; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/UnSubscribeResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/UnSubscribeResponseBody.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/UnSubscribeResponseBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/UnSubscribeResponseBody.java index 6aac822772..d62b9d9de3 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/client/UnSubscribeResponseBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/client/UnSubscribeResponseBody.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.client; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.body.Body; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import org.apache.commons.lang3.time.DateFormatUtils; +package org.apache.eventmesh.common.protocol.http.body.client; 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; + public class UnSubscribeResponseBody extends Body { private Integer retCode; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java similarity index 97% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java index 2613af74aa..accefa66c8 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java @@ -15,16 +15,17 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.message; +package org.apache.eventmesh.common.protocol.http.body.message; + +import java.util.HashMap; +import java.util.Map; -import com.webank.eventmesh.common.protocol.http.body.Body; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; + import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; - -import java.util.HashMap; -import java.util.Map; +import org.apache.eventmesh.common.protocol.http.body.Body; public class PushMessageRequestBody extends Body { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/PushMessageResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageResponseBody.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/PushMessageResponseBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageResponseBody.java index 8b1f28e5a2..a5ac0d1658 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/PushMessageResponseBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageResponseBody.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.message; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.body.Body; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import org.apache.commons.lang3.time.DateFormatUtils; +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; + public class PushMessageResponseBody extends Body { private Integer retCode; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java similarity index 94% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java index ba8ba94e64..ddd29e5a6d 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java @@ -15,16 +15,17 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.message; +package org.apache.eventmesh.common.protocol.http.body.message; + +import java.util.HashMap; +import java.util.Map; -import com.webank.eventmesh.common.protocol.http.body.Body; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; + import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; - -import java.util.HashMap; -import java.util.Map; +import org.apache.eventmesh.common.protocol.http.body.Body; public class ReplyMessageRequestBody extends Body { @@ -94,7 +95,7 @@ public static ReplyMessageRequestBody buildBody(Map bodyParam) { body.setOrigTopic(MapUtils.getString(bodyParam, ORIGTOPIC)); String extFields = MapUtils.getString(bodyParam, EXTFIELDS); if (StringUtils.isNotBlank(extFields)) { - body.setExtFields((HashMap)JSONObject.parseObject(extFields, HashMap.class)); + body.setExtFields((HashMap) JSONObject.parseObject(extFields, HashMap.class)); } return body; } diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/ReplyMessageResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageResponseBody.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/ReplyMessageResponseBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageResponseBody.java index 99b6a42939..b5a2069481 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/ReplyMessageResponseBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageResponseBody.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.message; - -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.body.Body; -import org.apache.commons.lang3.time.DateFormatUtils; +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; + public class ReplyMessageResponseBody extends Body { //响应码 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageBatchRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchRequestBody.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageBatchRequestBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchRequestBody.java index 067d398c06..ced6bef3c5 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageBatchRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchRequestBody.java @@ -15,17 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.message; +package org.apache.eventmesh.common.protocol.http.body.message; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import com.webank.eventmesh.common.protocol.http.body.Body; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; + import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import org.apache.eventmesh.common.protocol.http.body.Body; public class SendMessageBatchRequestBody extends Body { @@ -100,7 +101,7 @@ public static SendMessageBatchRequestBody buildBody(final Map bo String batchId = MapUtils.getString(bodyParam, BATCHID); String size = StringUtils.isBlank(MapUtils.getString(bodyParam, - SIZE)) ? "1" : MapUtils.getString(bodyParam, + SIZE)) ? "1" : MapUtils.getString(bodyParam, SIZE); String contents = MapUtils.getString(bodyParam, CONTENTS, null); diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageBatchResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchResponseBody.java similarity index 92% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageBatchResponseBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchResponseBody.java index 45ffb0dd7b..cf5ad72906 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageBatchResponseBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchResponseBody.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.message; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.body.Body; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import org.apache.commons.lang3.time.DateFormatUtils; +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; + public class SendMessageBatchResponseBody extends Body { //响应码 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java similarity index 96% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java index 3532da883c..dc46adc92b 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.message; - -import com.webank.eventmesh.common.protocol.http.body.Body; -import org.apache.commons.collections4.MapUtils; +package org.apache.eventmesh.common.protocol.http.body.message; import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections4.MapUtils; +import org.apache.eventmesh.common.protocol.http.body.Body; + public class SendMessageBatchV2RequestBody extends Body { public static final String BIZSEQNO = "bizSeqNo"; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageBatchV2ResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2ResponseBody.java similarity index 92% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageBatchV2ResponseBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2ResponseBody.java index bc5d9b1b5e..fd0b49a22c 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageBatchV2ResponseBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2ResponseBody.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.message; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.body.Body; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import org.apache.commons.lang3.time.DateFormatUtils; +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; + public class SendMessageBatchV2ResponseBody extends Body { //响应码 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java similarity index 97% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java index 02007ce051..840e2f7804 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.message; +package org.apache.eventmesh.common.protocol.http.body.message; import java.util.HashMap; import java.util.Map; import com.alibaba.fastjson.JSONObject; -import com.webank.eventmesh.common.protocol.http.body.Body; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.protocol.http.body.Body; public class SendMessageRequestBody extends Body { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java similarity index 92% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java index 375878439c..b9175a2c74 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.body.message; - -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.body.Body; -import org.apache.commons.lang3.time.DateFormatUtils; +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; + public class SendMessageResponseBody extends Body { private Integer retCode; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/ClientRetCode.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ClientRetCode.java similarity index 97% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/ClientRetCode.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ClientRetCode.java index 17f7e77e15..30986efa9c 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/ClientRetCode.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ClientRetCode.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.common; +package org.apache.eventmesh.common.protocol.http.common; public enum ClientRetCode { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/ClientType.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ClientType.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/ClientType.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ClientType.java index 4ddeb826ab..fdebba5f3b 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/ClientType.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ClientType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.common; +package org.apache.eventmesh.common.protocol.http.common; public enum ClientType { @@ -44,8 +44,8 @@ public static ClientType get(Integer type) { public static boolean contains(Integer clientType) { boolean flag = false; - for(ClientType ct:ClientType.values()) { - if(ct.type == clientType.intValue()) { + for (ClientType ct : ClientType.values()) { + if (ct.type == clientType.intValue()) { flag = true; break; } diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/EventMeshRetCode.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/EventMeshRetCode.java similarity index 97% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/EventMeshRetCode.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/EventMeshRetCode.java index 371a4564bd..3593e0e40c 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/EventMeshRetCode.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/EventMeshRetCode.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.common; +package org.apache.eventmesh.common.protocol.http.common; public enum EventMeshRetCode { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/ProtocolKey.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java similarity index 97% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/ProtocolKey.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java index c7f87e058d..c6cb15d4dd 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/ProtocolKey.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.common; +package org.apache.eventmesh.common.protocol.http.common; public class ProtocolKey { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/ProtocolVersion.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolVersion.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/ProtocolVersion.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolVersion.java index 9c3e14e05a..acfd655246 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/ProtocolVersion.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolVersion.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.common; +package org.apache.eventmesh.common.protocol.http.common; public enum ProtocolVersion { @@ -29,9 +29,9 @@ public enum ProtocolVersion { } public static ProtocolVersion get(String version) { - if(V1.version.equals(version)) { + if (V1.version.equals(version)) { return V1; - } else if(V2.version.equals(version)) { + } else if (V2.version.equals(version)) { return V2; } else { return null; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/RequestCode.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/RequestCode.java similarity index 97% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/RequestCode.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/RequestCode.java index dd6c4341b0..f193884faa 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/common/RequestCode.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/RequestCode.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.common; +package org.apache.eventmesh.common.protocol.http.common; public enum RequestCode { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/BaseRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/BaseRequestHeader.java similarity index 93% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/BaseRequestHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/BaseRequestHeader.java index 962c2600c1..d58919e3c4 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/BaseRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/BaseRequestHeader.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header; - -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import org.apache.commons.collections4.MapUtils; +package org.apache.eventmesh.common.protocol.http.header; import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections4.MapUtils; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; + public class BaseRequestHeader extends Header { private String code; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/BaseResponseHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/BaseResponseHeader.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/BaseResponseHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/BaseResponseHeader.java index 30cbbbdd7f..cd7bbaf59b 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/BaseResponseHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/BaseResponseHeader.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header; +package org.apache.eventmesh.common.protocol.http.header; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; - import java.util.HashMap; import java.util.Map; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; + public class BaseResponseHeader extends Header { private String code; @@ -41,7 +41,7 @@ public static BaseResponseHeader buildHeader(String code) { return baseResponseHeader; } - @Override + @Override public Map toMap() { Map map = new HashMap<>(); map.put(ProtocolKey.REQUEST_CODE, code); diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/Header.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/Header.java similarity index 77% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/Header.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/Header.java index 3f7f09e2a8..f2e44108e5 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/Header.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/Header.java @@ -15,21 +15,23 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header; +package org.apache.eventmesh.common.protocol.http.header; -import com.webank.eventmesh.common.protocol.http.body.client.HeartbeatRequestBody; -import com.webank.eventmesh.common.protocol.http.body.message.ReplyMessageRequestBody; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.common.protocol.http.header.client.*; -import com.webank.eventmesh.common.protocol.http.header.message.PushMessageRequestHeader; -import com.webank.eventmesh.common.protocol.http.header.message.SendMessageBatchV2RequestHeader; -import com.webank.eventmesh.common.protocol.http.header.message.SendMessageRequestHeader; -import com.webank.eventmesh.common.protocol.http.header.message.ReplyMessageRequestHeader; -import com.webank.eventmesh.common.protocol.http.header.message.SendMessageBatchRequestHeader; - import java.util.Map; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.protocol.http.header.client.HeartbeatRequestHeader; +import org.apache.eventmesh.common.protocol.http.header.client.RegRequestHeader; +import org.apache.eventmesh.common.protocol.http.header.client.SubscribeRequestHeader; +import org.apache.eventmesh.common.protocol.http.header.client.UnRegRequestHeader; +import org.apache.eventmesh.common.protocol.http.header.client.UnSubscribeRequestHeader; +import org.apache.eventmesh.common.protocol.http.header.message.PushMessageRequestHeader; +import org.apache.eventmesh.common.protocol.http.header.message.ReplyMessageRequestHeader; +import org.apache.eventmesh.common.protocol.http.header.message.SendMessageBatchRequestHeader; +import org.apache.eventmesh.common.protocol.http.header.message.SendMessageBatchV2RequestHeader; +import org.apache.eventmesh.common.protocol.http.header.message.SendMessageRequestHeader; + public abstract class Header { public abstract Map toMap(); @@ -37,7 +39,8 @@ public abstract class Header { public static Header buildHeader(String requestCode, Map originalMap) throws Exception { if (String.valueOf(RequestCode.MSG_BATCH_SEND.getRequestCode()).equals(requestCode)) { return SendMessageBatchRequestHeader.buildHeader(originalMap); - } if (String.valueOf(RequestCode.MSG_BATCH_SEND_V2.getRequestCode()).equals(requestCode)) { + } + if (String.valueOf(RequestCode.MSG_BATCH_SEND_V2.getRequestCode()).equals(requestCode)) { return SendMessageBatchV2RequestHeader.buildHeader(originalMap); } else if (String.valueOf(RequestCode.MSG_SEND_SYNC.getRequestCode()).equals(requestCode)) { return SendMessageRequestHeader.buildHeader(originalMap); diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/HeartbeatRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/HeartbeatRequestHeader.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/HeartbeatRequestHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/HeartbeatRequestHeader.java index 263411ab7a..e189823151 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/HeartbeatRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/HeartbeatRequestHeader.java @@ -15,18 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.client; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.header.Header; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; +package org.apache.eventmesh.common.protocol.http.header.client; import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.Constants; +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; + public class HeartbeatRequestHeader extends Header { //请求码 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/HeartbeatResponseHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/HeartbeatResponseHeader.java similarity index 93% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/HeartbeatResponseHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/HeartbeatResponseHeader.java index 978f444c34..3863498392 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/HeartbeatResponseHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/HeartbeatResponseHeader.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.client; +package org.apache.eventmesh.common.protocol.http.header.client; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.header.Header; - import java.util.HashMap; import java.util.Map; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.header.Header; + public class HeartbeatResponseHeader extends Header { private int code; @@ -97,7 +97,7 @@ public void setEventMeshDcn(String eventMeshDcn) { } public static HeartbeatResponseHeader buildHeader(Integer requestCode, String eventMeshCluster, - String eventMeshIp, String eventMeshEnv, String eventMeshRegion, + String eventMeshIp, String eventMeshEnv, String eventMeshRegion, String eventMeshDcn, String eventMeshIDC) { HeartbeatResponseHeader heartbeatResponseHeader = new HeartbeatResponseHeader(); heartbeatResponseHeader.setCode(requestCode); diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/RegRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/RegRequestHeader.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/RegRequestHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/RegRequestHeader.java index 1ed7bc3643..2dbcd6f094 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/RegRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/RegRequestHeader.java @@ -15,18 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.client; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.header.Header; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; +package org.apache.eventmesh.common.protocol.http.header.client; import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.Constants; +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; + public class RegRequestHeader extends Header { private String code; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/RegResponseHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/RegResponseHeader.java similarity index 93% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/RegResponseHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/RegResponseHeader.java index b380d57201..d0257cc9d6 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/RegResponseHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/RegResponseHeader.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.client; +package org.apache.eventmesh.common.protocol.http.header.client; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.header.Header; - import java.util.HashMap; import java.util.Map; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.header.Header; + public class RegResponseHeader extends Header { //响应码, 与对应Request的code一致 @@ -104,7 +104,7 @@ public void setEventMeshDcn(String eventMeshDcn) { } public static RegResponseHeader buildHeader(Integer requestCode, String eventMeshCluster, - String eventMeshIp, String eventMeshEnv, String eventMeshRegion, + String eventMeshIp, String eventMeshEnv, String eventMeshRegion, String eventMeshDcn, String eventMeshIDC) { RegResponseHeader regResponseHeader = new RegResponseHeader(); regResponseHeader.setCode(requestCode); diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/SubscribeRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/SubscribeRequestHeader.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/SubscribeRequestHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/SubscribeRequestHeader.java index a4f90855fd..9fffa22f2e 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/SubscribeRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/SubscribeRequestHeader.java @@ -15,18 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.client; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.header.Header; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; +package org.apache.eventmesh.common.protocol.http.header.client; import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.Constants; +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; + public class SubscribeRequestHeader extends Header { private String code; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/SubscribeResponseHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/SubscribeResponseHeader.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/SubscribeResponseHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/SubscribeResponseHeader.java index 931d5c632b..dbd9bb0241 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/SubscribeResponseHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/SubscribeResponseHeader.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.client; - -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.header.Header; +package org.apache.eventmesh.common.protocol.http.header.client; import java.util.HashMap; import java.util.Map; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.header.Header; + public class SubscribeResponseHeader extends Header { private int code; @@ -96,8 +96,8 @@ public void setEventMeshDcn(String eventMeshDcn) { } public static SubscribeResponseHeader buildHeader(Integer requestCode, String eventMeshCluster, - String eventMeshIp, String eventMeshEnv, String eventMeshRegion, - String eventMeshDcn, String eventMeshIDC) { + String eventMeshIp, String eventMeshEnv, String eventMeshRegion, + String eventMeshDcn, String eventMeshIDC) { SubscribeResponseHeader subscribeResponseHeader = new SubscribeResponseHeader(); subscribeResponseHeader.setCode(requestCode); subscribeResponseHeader.setEventMeshCluster(eventMeshCluster); diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/UnRegRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/UnRegRequestHeader.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/UnRegRequestHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/UnRegRequestHeader.java index ce6fb8e22c..9e040d234f 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/UnRegRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/UnRegRequestHeader.java @@ -15,18 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.client; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.header.Header; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; +package org.apache.eventmesh.common.protocol.http.header.client; import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.Constants; +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; + public class UnRegRequestHeader extends Header { //请求码 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/UnRegResponseHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/UnRegResponseHeader.java similarity index 93% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/UnRegResponseHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/UnRegResponseHeader.java index c6a91c6891..d009228421 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/UnRegResponseHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/UnRegResponseHeader.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.client; +package org.apache.eventmesh.common.protocol.http.header.client; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.header.Header; - import java.util.HashMap; import java.util.Map; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.header.Header; + public class UnRegResponseHeader extends Header { private int code; @@ -97,7 +97,7 @@ public void setEventMeshDcn(String eventMeshDcn) { } public static UnRegResponseHeader buildHeader(Integer requestCode, String eventMeshCluster, - String eventMeshIp, String eventMeshEnv, String eventMeshRegion, + String eventMeshIp, String eventMeshEnv, String eventMeshRegion, String eventMeshDcn, String eventMeshIDC) { UnRegResponseHeader regResponseHeader = new UnRegResponseHeader(); regResponseHeader.setCode(requestCode); diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/UnSubscribeRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/UnSubscribeRequestHeader.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/UnSubscribeRequestHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/UnSubscribeRequestHeader.java index 7cc3650627..0c505eef2b 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/UnSubscribeRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/UnSubscribeRequestHeader.java @@ -15,18 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.client; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.header.Header; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; +package org.apache.eventmesh.common.protocol.http.header.client; import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.Constants; +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; + public class UnSubscribeRequestHeader extends Header { private String code; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/UnSubscribeResponseHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/UnSubscribeResponseHeader.java similarity index 91% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/UnSubscribeResponseHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/UnSubscribeResponseHeader.java index 486a40f3b8..f6e15be3e1 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/client/UnSubscribeResponseHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/client/UnSubscribeResponseHeader.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.client; - -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.header.Header; +package org.apache.eventmesh.common.protocol.http.header.client; import java.util.HashMap; import java.util.Map; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.header.Header; + public class UnSubscribeResponseHeader extends Header { private int code; @@ -96,8 +96,8 @@ public void setEventMeshDcn(String eventMeshDcn) { } public static UnSubscribeResponseHeader buildHeader(Integer requestCode, String eventMeshCluster, - String eventMeshIp, String eventMeshEnv, String eventMeshRegion, - String eventMeshDcn, String eventMeshIDC) { + String eventMeshIp, String eventMeshEnv, String eventMeshRegion, + String eventMeshDcn, String eventMeshIDC) { UnSubscribeResponseHeader unSubscribeResponseHeader = new UnSubscribeResponseHeader(); unSubscribeResponseHeader.setCode(requestCode); unSubscribeResponseHeader.setEventMeshCluster(eventMeshCluster); diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/PushMessageRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/PushMessageRequestHeader.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/PushMessageRequestHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/PushMessageRequestHeader.java index 8ea85ae253..e0b3fa9f01 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/PushMessageRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/PushMessageRequestHeader.java @@ -15,18 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.message; +package org.apache.eventmesh.common.protocol.http.header.message; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.header.Header; -import org.apache.commons.collections4.MapUtils; - import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections4.MapUtils; +import org.apache.eventmesh.common.Constants; +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; + public class PushMessageRequestHeader extends Header { //请求码 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/PushMessageResponseHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/PushMessageResponseHeader.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/PushMessageResponseHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/PushMessageResponseHeader.java index fa0af32fa5..9571ba5d85 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/PushMessageResponseHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/PushMessageResponseHeader.java @@ -15,18 +15,17 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.message; +package org.apache.eventmesh.common.protocol.http.header.message; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.header.Header; - import java.util.HashMap; import java.util.Map; +import org.apache.eventmesh.common.Constants; +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; + public class PushMessageResponseHeader extends Header { //响应码 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java index 0a22a8b071..3a25164787 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java @@ -15,18 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.message; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.header.Header; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; +package org.apache.eventmesh.common.protocol.http.header.message; import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.Constants; +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; + public class ReplyMessageRequestHeader extends Header { //请求码 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/ReplyMessageResponseHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageResponseHeader.java similarity index 94% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/ReplyMessageResponseHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageResponseHeader.java index c1909f2c7c..fb2f42f06d 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/ReplyMessageResponseHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageResponseHeader.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.message; +package org.apache.eventmesh.common.protocol.http.header.message; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.header.Header; - import java.util.HashMap; import java.util.Map; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.header.Header; + public class ReplyMessageResponseHeader extends Header { //响应码, 与对应Request的code一致 @@ -104,7 +104,7 @@ public void setEventMeshDcn(String eventMeshDcn) { } public static ReplyMessageResponseHeader buildHeader(Integer requestCode, String eventMeshCluster, - String eventMeshIp, String eventMeshEnv, String eventMeshRegion, + String eventMeshIp, String eventMeshEnv, String eventMeshRegion, String eventMeshDcn, String eventMeshIDC) { ReplyMessageResponseHeader replyMessageResponseHeader = new ReplyMessageResponseHeader(); replyMessageResponseHeader.setCode(requestCode); diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java index 041e6ed4ce..fd62ccefcd 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java @@ -15,19 +15,19 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.message; +package org.apache.eventmesh.common.protocol.http.header.message; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.header.Header; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; - import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.Constants; +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; + public class SendMessageBatchRequestHeader extends Header { //请求码 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageBatchResponseHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchResponseHeader.java similarity index 96% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageBatchResponseHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchResponseHeader.java index 55a4750f38..c008ed3cb1 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageBatchResponseHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchResponseHeader.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.message; +package org.apache.eventmesh.common.protocol.http.header.message; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.header.Header; - import java.util.HashMap; import java.util.Map; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.header.Header; + public class SendMessageBatchResponseHeader extends Header { //响应码, 与对应Request的code一致 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java index 7a2972612b..8722d68a0d 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java @@ -15,18 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.message; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.header.Header; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; +package org.apache.eventmesh.common.protocol.http.header.message; import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.Constants; +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; + public class SendMessageBatchV2RequestHeader extends Header { //请求码 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageBatchV2ResponseHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2ResponseHeader.java similarity index 96% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageBatchV2ResponseHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2ResponseHeader.java index 0f44084c75..c284fc0d59 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageBatchV2ResponseHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2ResponseHeader.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.message; - -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.header.Header; +package org.apache.eventmesh.common.protocol.http.header.message; import java.util.HashMap; import java.util.Map; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.header.Header; + public class SendMessageBatchV2ResponseHeader extends Header { //响应码, 与对应Request的code一致 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java similarity index 95% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java index 515f0dfc3d..3a1778f7ff 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java @@ -15,18 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.message; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.header.Header; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; +package org.apache.eventmesh.common.protocol.http.header.message; import java.util.HashMap; import java.util.Map; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.Constants; +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; + public class SendMessageRequestHeader extends Header { //请求码 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageResponseHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageResponseHeader.java similarity index 96% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageResponseHeader.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageResponseHeader.java index 5a89ad4adb..2f14bd6749 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/http/header/message/SendMessageResponseHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageResponseHeader.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.http.header.message; +package org.apache.eventmesh.common.protocol.http.header.message; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.header.Header; - import java.util.HashMap; import java.util.Map; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.header.Header; + public class SendMessageResponseHeader extends Header { //响应码, 与对应Request的code一致 diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/Command.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Command.java similarity index 99% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/Command.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Command.java index d9b3e028c4..54d75b4a61 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/Command.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Command.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.tcp; +package org.apache.eventmesh.common.protocol.tcp; public enum Command { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/EventMeshClientInfo.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshClientInfo.java similarity index 98% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/EventMeshClientInfo.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshClientInfo.java index 1ae9365b95..93616b2b8e 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/EventMeshClientInfo.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshClientInfo.java @@ -15,7 +15,7 @@ // * limitations under the License. // */ // -//package com.webank.eventmesh.common.protocol.tcp; +//package org.apache.eventmesh.common.protocol.tcp; // //import org.apache.rocketmq.common.DataVersion; // diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/EventMeshMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshMessage.java similarity index 97% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/EventMeshMessage.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshMessage.java index 2918a95449..01d744eea1 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/EventMeshMessage.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshMessage.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.tcp; +package org.apache.eventmesh.common.protocol.tcp; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/Header.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Header.java similarity index 97% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/Header.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Header.java index 70a51075e3..1df51427c8 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/Header.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Header.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.tcp; +package org.apache.eventmesh.common.protocol.tcp; public class Header { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/HeartBeatInfo.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/HeartBeatInfo.java similarity index 97% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/HeartBeatInfo.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/HeartBeatInfo.java index 0e421eb966..c12d6917d2 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/HeartBeatInfo.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/HeartBeatInfo.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.tcp; +package org.apache.eventmesh.common.protocol.tcp; import java.util.List; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/OPStatus.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/OPStatus.java similarity index 96% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/OPStatus.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/OPStatus.java index 56089c4e39..4ecfd04dbc 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/OPStatus.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/OPStatus.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.tcp; +package org.apache.eventmesh.common.protocol.tcp; public enum OPStatus { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/Package.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Package.java similarity index 96% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/Package.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Package.java index 051c3223e2..d2cde02193 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/Package.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Package.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.tcp; +package org.apache.eventmesh.common.protocol.tcp; public class Package { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/RedirectInfo.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/RedirectInfo.java similarity index 96% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/RedirectInfo.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/RedirectInfo.java index 40a19db587..81373f8485 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/RedirectInfo.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/RedirectInfo.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.tcp; +package org.apache.eventmesh.common.protocol.tcp; public class RedirectInfo { private String ip; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/RegisterInfo.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/RegisterInfo.java similarity index 96% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/RegisterInfo.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/RegisterInfo.java index 0e5867506e..44303f2f58 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/RegisterInfo.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/RegisterInfo.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.tcp; +package org.apache.eventmesh.common.protocol.tcp; import java.util.List; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/Subscription.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Subscription.java similarity index 96% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/Subscription.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Subscription.java index 2c965bcc36..83b0dc9fcc 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/Subscription.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Subscription.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.tcp; +package org.apache.eventmesh.common.protocol.tcp; import java.util.LinkedList; import java.util.List; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/UnRegisterInfo.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UnRegisterInfo.java similarity index 97% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/UnRegisterInfo.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UnRegisterInfo.java index 6c0626de7a..33961ad486 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/UnRegisterInfo.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UnRegisterInfo.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.tcp; +package org.apache.eventmesh.common.protocol.tcp; import java.util.List; diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/UserAgent.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UserAgent.java similarity index 99% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/UserAgent.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UserAgent.java index 07200a70d3..27ba693929 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/UserAgent.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UserAgent.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.tcp; +package org.apache.eventmesh.common.protocol.tcp; public class UserAgent { diff --git a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/codec/Codec.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java similarity index 93% rename from eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/codec/Codec.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java index b7f7e4ef93..d520e04dbc 100644 --- a/eventmesh-common/src/main/java/com/webank/eventmesh/common/protocol/tcp/codec/Codec.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java @@ -15,31 +15,33 @@ * limitations under the License. */ -package com.webank.eventmesh.common.protocol.tcp.codec; - -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.RedirectInfo; -import com.webank.eventmesh.common.protocol.tcp.Subscription; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; +package org.apache.eventmesh.common.protocol.tcp.codec; + +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.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; + import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.ReplayingDecoder; + +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; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.List; -import java.util.TimeZone; - public class Codec { private final static Logger logger = LoggerFactory.getLogger(Codec.class); diff --git a/eventmesh-connector-api/build.gradle b/eventmesh-connector-api/build.gradle index bf71a34be7..2d1205df38 100644 --- a/eventmesh-connector-api/build.gradle +++ b/eventmesh-connector-api/build.gradle @@ -15,55 +15,11 @@ * limitations under the License. */ -apply plugin: 'java' -apply plugin: "maven" -apply plugin: "eclipse" -apply plugin: "idea" - -if (project.findProperty("jdk") == "1.7") { - sourceCompatibility = 1.7 - targetCompatibility = 1.7 -} else { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - version = version + "-jdk8" -} - -if (project.findProperty("snapshot") instanceof String) { - if (project.property("snapshot").toBoolean()) version = version + "-SNAPSHOT" -} - -repositories { - mavenLocal() - maven { - url "https://maven.aliyun.com/repository/public" - } - mavenCentral() -} - List open_message = [ "io.openmessaging:openmessaging-api:2.2.1-pubsub" ] dependencies { - compile project(":eventmesh-common") - compile open_message - testCompile group: 'junit', name: 'junit', version: '4.12', open_message -} - -uploadArchives { - repositories { - mavenDeployer { - snapshotRepository(url: 'Your target repo address') { - authentication(userName: 'Your user name', password: 'Your password') - } - repository(url: 'Your target repo address') { - authentication(userName: 'Your user name', password: 'Your password') - } - } - } -} - -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" + implementation open_message,project(":eventmesh-common") + testImplementation open_message,project(":eventmesh-common") } diff --git a/eventmesh-connector-api/gradle.properties b/eventmesh-connector-api/gradle.properties index 0c63593fb4..ae30087cf9 100644 --- a/eventmesh-connector-api/gradle.properties +++ b/eventmesh-connector-api/gradle.properties @@ -14,8 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # - -group=com.webank.eventmesh +group=org.apache.eventmesh version=1.2.0-SNAPSHOT jdk=1.7 mavenUserName= diff --git a/eventmesh-connector-api/src/main/java/com/webank/eventmesh/api/AbstractContext.java b/eventmesh-connector-api/src/main/java/com/webank/eventmesh/api/AbstractContext.java deleted file mode 100644 index 4d76140d01..0000000000 --- a/eventmesh-connector-api/src/main/java/com/webank/eventmesh/api/AbstractContext.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.webank.eventmesh.api; - -public interface AbstractContext { -} diff --git a/eventmesh-connector-api/src/main/java/com/webank/eventmesh/api/RRCallback.java b/eventmesh-connector-api/src/main/java/com/webank/eventmesh/api/RRCallback.java deleted file mode 100644 index d72ccbbca2..0000000000 --- a/eventmesh-connector-api/src/main/java/com/webank/eventmesh/api/RRCallback.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.webank.eventmesh.api; - -import io.openmessaging.api.Message; - -public interface RRCallback { - - public void onSuccess(Message msg); - - public void onException(Throwable e); - -} diff --git a/eventmesh-connector-api/src/main/java/com/webank/eventmesh/api/consumer/MeshMQPushConsumer.java b/eventmesh-connector-api/src/main/java/com/webank/eventmesh/api/consumer/MeshMQPushConsumer.java deleted file mode 100644 index a18ce443b5..0000000000 --- a/eventmesh-connector-api/src/main/java/com/webank/eventmesh/api/consumer/MeshMQPushConsumer.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.webank.eventmesh.api.consumer; - -import com.webank.eventmesh.api.AbstractContext; -import io.openmessaging.api.AsyncMessageListener; -import io.openmessaging.api.MessageListener; -import io.openmessaging.api.Message; -import io.openmessaging.api.Consumer; - -import java.util.List; -import java.util.Properties; - -public interface MeshMQPushConsumer extends Consumer { - - void init(Properties keyValue) throws Exception; - - @Override - void start(); - -// void updateOffset(List msgs, ConsumeConcurrentlyContext context); - - void updateOffset(List msgs, AbstractContext context); - -// void registerMessageListener(MessageListenerConcurrently messageListenerConcurrently); - - void subscribe(String topic, final AsyncMessageListener listener) throws Exception; - - @Override - void unsubscribe(String topic); - - AbstractContext getContext(); -} diff --git a/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/AbstractContext.java b/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/AbstractContext.java new file mode 100644 index 0000000000..559a082bfc --- /dev/null +++ b/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/AbstractContext.java @@ -0,0 +1,21 @@ +/* + * Licensed 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 interface AbstractContext { +} diff --git a/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RRCallback.java b/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RRCallback.java new file mode 100644 index 0000000000..788f9f3906 --- /dev/null +++ b/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RRCallback.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.api; + +import io.openmessaging.api.Message; + +public interface RRCallback { + + public void onSuccess(Message msg); + + public void onException(Throwable e); + +} diff --git a/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/MeshMQPushConsumer.java b/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/MeshMQPushConsumer.java new file mode 100644 index 0000000000..b495169d20 --- /dev/null +++ b/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/MeshMQPushConsumer.java @@ -0,0 +1,48 @@ +/* + * Licensed 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.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; + +public interface MeshMQPushConsumer extends Consumer { + + void init(Properties keyValue) throws Exception; + + @Override + void start(); + +// void updateOffset(List msgs, ConsumeConcurrentlyContext context); + + void updateOffset(List msgs, AbstractContext context); + +// void registerMessageListener(MessageListenerConcurrently messageListenerConcurrently); + + void subscribe(String topic, final AsyncMessageListener listener) throws Exception; + + @Override + void unsubscribe(String topic); + + AbstractContext getContext(); +} diff --git a/eventmesh-connector-api/src/main/java/com/webank/eventmesh/api/producer/MeshMQProducer.java b/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/MeshMQProducer.java similarity index 94% rename from eventmesh-connector-api/src/main/java/com/webank/eventmesh/api/producer/MeshMQProducer.java rename to eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/MeshMQProducer.java index f20a879f4b..929654fb30 100644 --- a/eventmesh-connector-api/src/main/java/com/webank/eventmesh/api/producer/MeshMQProducer.java +++ b/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/MeshMQProducer.java @@ -15,14 +15,15 @@ * limitations under the License. */ -package com.webank.eventmesh.api.producer; +package org.apache.eventmesh.api.producer; + +import java.util.Properties; -import com.webank.eventmesh.api.RRCallback; import io.openmessaging.api.Message; import io.openmessaging.api.Producer; import io.openmessaging.api.SendCallback; -import java.util.Properties; +import org.apache.eventmesh.api.RRCallback; public interface MeshMQProducer extends Producer { diff --git a/eventmesh-connector-rocketmq/build.gradle b/eventmesh-connector-rocketmq/build.gradle index b206b5b436..6126b50609 100644 --- a/eventmesh-connector-rocketmq/build.gradle +++ b/eventmesh-connector-rocketmq/build.gradle @@ -1,21 +1,29 @@ -import java.util.concurrent.TimeUnit - -apply plugin: 'java' -apply plugin: "maven" -apply plugin: "eclipse" -apply plugin: "idea" - -sourceCompatibility = 1.8 +/* + * Licensed 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. + */ + +//apply plugin: 'java' +////apply plugin: "maven" +//apply plugin: "eclipse" +//apply plugin: "idea" +// +//sourceCompatibility = 1.8 configurations { - compile.exclude group: 'ch.qos.logback', module: 'logback-classic' -} -repositories { - mavenLocal() - maven { - url "https://maven.aliyun.com/repository/public" - } - mavenCentral() + implementation.exclude group: 'ch.qos.logback', module: 'logback-classic' } List rocketmq = [ @@ -35,22 +43,6 @@ List rocketmq = [ ] -List junit = [ - "junit:junit:4.12" -] - -List log4j2 = [ - "org.apache.logging.log4j:log4j-api:2.13.3", - "org.apache.logging.log4j:log4j-core:2.13.3", - "org.apache.logging.log4j:log4j-slf4j-impl:2.13.3", - "org.apache.logging.log4j:log4j-web:2.13.3", - "com.lmax:disruptor:3.4.2" -] - -List sl4j = [ - "org.slf4j:slf4j-api:1.7.30" -] - List metrics = [ "io.dropwizard.metrics:metrics-core:4.1.0", "io.dropwizard.metrics:metrics-healthchecks:4.1.0", @@ -58,107 +50,11 @@ List metrics = [ "io.dropwizard.metrics:metrics-json:4.1.0" ] -dependencies { - compile project(":eventmesh-connector-api") - testCompile project(":eventmesh-connector-api") - compile rocketmq, metrics, log4j2, sl4j - testCompile rocketmq, metrics, log4j2, sl4j, junit -} +List open_message = [ + "io.openmessaging:openmessaging-api:2.2.1-pubsub" +] -clean.doFirst { - delete 'build' - delete 'dist' +dependencies { + implementation rocketmq, metrics,open_message,project(":eventmesh-connector-api"),project(":eventmesh-common") + testImplementation rocketmq, metrics,open_message,project(":eventmesh-connector-api"),project(":eventmesh-common") } - -//jar { -// from { -// configurations.runtime.collect{zipTree(it)} -// } -//} - -//def versionString = project.version -//if (project.findProperty("buildNo") instanceof String) { -// versionString = project.version + '_' + project.property("buildNo") -//} - -//task zip(type: Zip, dependsOn: ['clean', 'jar']) { -// extension = 'zip' -// archiveName = project.name + '_' + versionString + '.' + extension -// destinationDir = new File(projectDir, 'dist') -// -// into('apps') { -// from project.jar.getArchivePath() -// } -// -// into('bin') { -// from 'bin' -// } -// -// into('conf') { -// from "conf" -// } -// -// into('lib') { -// from project.configurations.runtime -// exclude '**/*.properties*' -// exclude '**/*testng*.jar' -// exclude '**/*powermock*.jar' -// exclude '**/*mockito*.jar' -// exclude '**/*junit*.jar' -// exclude '**/*jacoco*.jar' -// exclude '**/*log4j2.xml*' -// exclude '**/spring-boot-devtools*.jar' -// } -// -// into('scripts') { -// from "scripts" -// } -//} -// -//task tar(type: Tar, dependsOn: ['clean', 'jar']) { -// extension = 'tar.gz' -// compression = Compression.GZIP -// archiveName = project.name + '_' + versionString + '.' + extension -// destinationDir = new File(projectDir, 'dist') -// -// into('apps') { -// from project.jar.getArchivePath() -// } -// -// into('bin') { -// from 'bin' -// } -// -// into('conf') { -// from "conf" -// } -// -// into('lib') { -// from project.configurations.runtime -// exclude '**/*.properties*' -// exclude '**/*testng*.jar' -// exclude '**/*powermock*.jar' -// exclude '**/*mockito*.jar' -// exclude '**/*junit*.jar' -// exclude '**/*jacoco*.jar' -// exclude '**/*log4j2.xml*' -// exclude '**/spring-boot-devtools*.jar' -// } -// -// into('scripts') { -// from "scripts" -// } -//} - -//uploadArchives { -// repositories { -// mavenDeployer { -// snapshotRepository(url: 'Your target repo address') { -// authentication(userName: 'Your user name', password: 'Your password') -// } -// repository(url: 'Your target repo address') { -// authentication(userName: 'Your user name', password: 'Your password') -// } -// } -// } -//} \ No newline at end of file diff --git a/eventmesh-connector-rocketmq/gradle.properties b/eventmesh-connector-rocketmq/gradle.properties index e3ec40aad7..931283f932 100644 --- a/eventmesh-connector-rocketmq/gradle.properties +++ b/eventmesh-connector-rocketmq/gradle.properties @@ -1,4 +1,3 @@ -# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. @@ -13,11 +12,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -# -group=com.webank.eventmesh -version=1.2.0 -defibus_version=1.0.1 +group=org.apache.eventmesh +version=1.2.0-SNAPSHOT rocketmq_version=4.7.1 mavenUserName= mavenPassword= \ No newline at end of file diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java similarity index 93% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java index 79d6a5f17e..f1b7ec79f1 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java @@ -14,10 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq; -import com.webank.eventmesh.connector.rocketmq.producer.ProducerImpl; -import com.webank.eventmesh.connector.rocketmq.consumer.PushConsumerImpl; +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; @@ -28,7 +29,8 @@ import io.openmessaging.api.transaction.LocalTransactionChecker; import io.openmessaging.api.transaction.TransactionProducer; -import java.util.Properties; +import org.apache.eventmesh.connector.rocketmq.consumer.PushConsumerImpl; +import org.apache.eventmesh.connector.rocketmq.producer.ProducerImpl; public class MessagingAccessPointImpl implements MessagingAccessPoint { diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/common/Constants.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/Constants.java similarity index 51% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/common/Constants.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/Constants.java index 969359da93..9d54a2ebef 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/common/Constants.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/Constants.java @@ -1,4 +1,21 @@ -package com.webank.eventmesh.connector.rocketmq.common; +/* + * Licensed 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.common; public class Constants { public static final String BROADCAST_PREFIX = "broadcast-"; diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/common/EventMeshConstants.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/EventMeshConstants.java similarity index 94% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/common/EventMeshConstants.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/EventMeshConstants.java index f3a1267397..cce1645ec1 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/common/EventMeshConstants.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/EventMeshConstants.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.common; +package org.apache.eventmesh.connector.rocketmq.common; public class EventMeshConstants { @@ -96,11 +96,11 @@ public class EventMeshConstants { 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-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/config/ClientConfig.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfig.java similarity index 97% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/config/ClientConfig.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfig.java index 9a0ebacce6..aad0b49a53 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/config/ClientConfig.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfig.java @@ -14,11 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.config; -import com.webank.eventmesh.connector.rocketmq.domain.NonStandardKeys; +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 { private String driverImpl; private String accessPoints; diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/config/ClientConfiguration.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfiguration.java similarity index 91% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/config/ClientConfiguration.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfiguration.java index 9277678e0d..11a1858a6e 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/config/ClientConfiguration.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfiguration.java @@ -15,9 +15,10 @@ * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.config; +package org.apache.eventmesh.connector.rocketmq.config; import com.google.common.base.Preconditions; + import org.apache.commons.lang3.StringUtils; public class ClientConfiguration { @@ -59,61 +60,61 @@ public void init() { namesrvAddr = StringUtils.trim(namesrvAddrStr); String consumeThreadPoolMinStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN); - if(StringUtils.isNotEmpty(consumeThreadPoolMinStr)){ + if (StringUtils.isNotEmpty(consumeThreadPoolMinStr)) { Preconditions.checkState(StringUtils.isNumeric(consumeThreadPoolMinStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN)); consumeThreadMin = Integer.valueOf(consumeThreadPoolMinStr); } String consumeThreadPoolMaxStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX); - if(StringUtils.isNotEmpty(consumeThreadPoolMaxStr)){ + if (StringUtils.isNotEmpty(consumeThreadPoolMaxStr)) { Preconditions.checkState(StringUtils.isNumeric(consumeThreadPoolMaxStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX)); consumeThreadMax = Integer.valueOf(consumeThreadPoolMaxStr); } String consumerThreadPoolQueueSizeStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE); - if(StringUtils.isNotEmpty(consumerThreadPoolQueueSizeStr)){ + if (StringUtils.isNotEmpty(consumerThreadPoolQueueSizeStr)) { Preconditions.checkState(StringUtils.isNumeric(consumerThreadPoolQueueSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE)); consumeQueueSize = Integer.valueOf(consumerThreadPoolQueueSizeStr); } String clientAckWindowStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_ACK_WINDOW); - if(StringUtils.isNotEmpty(clientAckWindowStr)){ + if (StringUtils.isNotEmpty(clientAckWindowStr)) { Preconditions.checkState(StringUtils.isNumeric(clientAckWindowStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_ACK_WINDOW)); ackWindow = Integer.valueOf(clientAckWindowStr); } String clientPubWindowStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PUB_WINDOW); - if(StringUtils.isNotEmpty(clientPubWindowStr)){ + if (StringUtils.isNotEmpty(clientPubWindowStr)) { Preconditions.checkState(StringUtils.isNumeric(clientPubWindowStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PUB_WINDOW)); pubWindow = Integer.valueOf(clientPubWindowStr); } String consumeTimeoutStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT); - if(StringUtils.isNotBlank(consumeTimeoutStr)) { + if (StringUtils.isNotBlank(consumeTimeoutStr)) { Preconditions.checkState(StringUtils.isNumeric(consumeTimeoutStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT)); consumeTimeout = Long.valueOf(consumeTimeoutStr); } String clientPullBatchSizeStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE); - if(StringUtils.isNotEmpty(clientPullBatchSizeStr)){ + if (StringUtils.isNotEmpty(clientPullBatchSizeStr)) { Preconditions.checkState(StringUtils.isNumeric(clientPullBatchSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE)); pullBatchSize = Integer.valueOf(clientPullBatchSizeStr); } String clientPollNamesrvIntervalStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL); - if(StringUtils.isNotEmpty(clientPollNamesrvIntervalStr)){ + if (StringUtils.isNotEmpty(clientPollNamesrvIntervalStr)) { Preconditions.checkState(StringUtils.isNumeric(clientPollNamesrvIntervalStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL)); pollNameServerInteval = Integer.valueOf(clientPollNamesrvIntervalStr); } String clientHeartbeatBrokerIntervalStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVEL); - if(StringUtils.isNotEmpty(clientHeartbeatBrokerIntervalStr)){ + if (StringUtils.isNotEmpty(clientHeartbeatBrokerIntervalStr)) { Preconditions.checkState(StringUtils.isNumeric(clientHeartbeatBrokerIntervalStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVEL)); heartbeatBrokerInterval = Integer.valueOf(clientHeartbeatBrokerIntervalStr); } String clientRebalanceIntervalIntervalStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVEL); - if(StringUtils.isNotEmpty(clientRebalanceIntervalIntervalStr)){ + if (StringUtils.isNotEmpty(clientRebalanceIntervalIntervalStr)) { Preconditions.checkState(StringUtils.isNumeric(clientRebalanceIntervalIntervalStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVEL)); rebalanceInterval = Integer.valueOf(clientRebalanceIntervalIntervalStr); } diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/config/ConfigurationWraper.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWraper.java similarity index 95% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/config/ConfigurationWraper.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWraper.java index 72ebf6d6fb..75003b137d 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/config/ConfigurationWraper.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWraper.java @@ -15,12 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.config; - -import com.webank.eventmesh.common.ThreadPoolFactory; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.connector.rocketmq.config; import java.io.BufferedReader; import java.io.File; @@ -30,6 +25,11 @@ 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; + public class ConfigurationWraper { public Logger logger = LoggerFactory.getLogger(this.getClass()); diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java similarity index 91% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java index 274a6a952c..2193ca1574 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java @@ -14,31 +14,41 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.consumer; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.connector.rocketmq.common.EventMeshConstants; -import com.webank.eventmesh.connector.rocketmq.domain.NonStandardKeys; -import com.webank.eventmesh.connector.rocketmq.patch.EventMeshConsumeConcurrentlyContext; -import com.webank.eventmesh.connector.rocketmq.patch.EventMeshConsumeConcurrentlyStatus; -import com.webank.eventmesh.connector.rocketmq.patch.EventMeshMessageListenerConcurrently; -import com.webank.eventmesh.connector.rocketmq.utils.BeanUtils; -import com.webank.eventmesh.connector.rocketmq.utils.OMSUtil; -import com.webank.eventmesh.connector.rocketmq.config.ClientConfig; -import com.webank.eventmesh.api.AbstractContext; -import io.openmessaging.api.*; + +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.Action; +import io.openmessaging.api.AsyncConsumeContext; +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.common.Constants; +import org.apache.eventmesh.connector.rocketmq.common.EventMeshConstants; +import org.apache.eventmesh.connector.rocketmq.config.ClientConfig; +import org.apache.eventmesh.connector.rocketmq.domain.NonStandardKeys; +import org.apache.eventmesh.connector.rocketmq.patch.EventMeshConsumeConcurrentlyContext; +import org.apache.eventmesh.connector.rocketmq.patch.EventMeshConsumeConcurrentlyStatus; +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.rocketmq.client.consumer.DefaultMQPushConsumer; import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.common.message.MessageExt; import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; import org.apache.rocketmq.remoting.protocol.LanguageCode; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; - public class PushConsumerImpl implements Consumer { private final DefaultMQPushConsumer rocketmqPushConsumer; private final Properties properties; @@ -78,13 +88,13 @@ public PushConsumerImpl(final Properties properties) { properties.put("CONSUMER_ID", consumerId); this.rocketmqPushConsumer.setLanguage(LanguageCode.OMS); - if (clientConfig.getMessageModel().equalsIgnoreCase(MessageModel.BROADCASTING.name())){ + if (clientConfig.getMessageModel().equalsIgnoreCase(MessageModel.BROADCASTING.name())) { rocketmqPushConsumer.registerMessageListener(new EventMeshMessageListenerConcurrently() { @Override public EventMeshConsumeConcurrentlyStatus handleMessage(MessageExt msg, EventMeshConsumeConcurrentlyContext context) { PushConsumerImpl.this.setContext(context); - if (msg == null){ + if (msg == null) { return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS; } @@ -118,7 +128,7 @@ public void commit(Action action) { return EventMeshConsumeConcurrentlyStatus.valueOf(contextProperties.getProperty(NonStandardKeys.MESSAGE_CONSUME_STATUS)); } }); - }else { + } else { rocketmqPushConsumer.registerMessageListener(new EventMeshMessageListenerConcurrently() { @Override diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java similarity index 83% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java index a39d045984..ce076f8003 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java @@ -15,17 +15,31 @@ * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.consumer; - -import com.webank.eventmesh.api.AbstractContext; -import com.webank.eventmesh.api.consumer.MeshMQPushConsumer; -import com.webank.eventmesh.connector.rocketmq.common.Constants; -import com.webank.eventmesh.connector.rocketmq.common.EventMeshConstants; -import com.webank.eventmesh.connector.rocketmq.config.ClientConfiguration; -import com.webank.eventmesh.connector.rocketmq.config.ConfigurationWraper; -import com.webank.eventmesh.connector.rocketmq.patch.EventMeshConsumeConcurrentlyContext; -import com.webank.eventmesh.connector.rocketmq.utils.OMSUtil; -import io.openmessaging.api.*; +package org.apache.eventmesh.connector.rocketmq.consumer; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +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.openmessaging.api.OMS; +import io.openmessaging.api.OMSBuiltinKeys; + +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.api.consumer.MeshMQPushConsumer; +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.ConfigurationWraper; +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; @@ -33,18 +47,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - public class RocketMQConsumerImpl implements MeshMQPushConsumer { public Logger logger = LoggerFactory.getLogger(this.getClass()); public Logger messageLogger = LoggerFactory.getLogger("message"); - public final String DEFAULT_ACCESS_DRIVER = "com.webank.eventmesh.connector.rocketmq.MessagingAccessPointImpl"; + public final String DEFAULT_ACCESS_DRIVER = "org.apache.eventmesh.connector.rocketmq.MessagingAccessPointImpl"; private PushConsumerImpl pushConsumer; @@ -61,9 +70,9 @@ public synchronized void init(Properties keyValue) throws Exception { String instanceName = keyValue.getProperty("instanceName"); - if(isBroadcast){ + if (isBroadcast) { consumerGroup = Constants.CONSUMER_GROUP_NAME_PREFIX + Constants.BROADCAST_PREFIX + consumerGroup; - }else { + } else { consumerGroup = Constants.CONSUMER_GROUP_NAME_PREFIX + consumerGroup; } @@ -75,13 +84,13 @@ public synchronized void init(Properties keyValue) throws Exception { properties.put("REGION", "namespace"); properties.put("instanceName", instanceName); properties.put("CONSUMER_ID", consumerGroup); - if (isBroadcast){ + if (isBroadcast) { properties.put("MESSAGE_MODEL", MessageModel.BROADCASTING.name()); - }else { + } else { properties.put("MESSAGE_MODEL", MessageModel.CLUSTERING.name()); } MessagingAccessPoint messagingAccessPoint = OMS.builder().build(properties); - pushConsumer = (PushConsumerImpl)messagingAccessPoint.createConsumer(properties); + pushConsumer = (PushConsumerImpl) messagingAccessPoint.createConsumer(properties); } @Override @@ -114,7 +123,7 @@ public synchronized void start() { public void updateOffset(List msgs, AbstractContext context) { ConsumeMessageService consumeMessageService = pushConsumer.getRocketmqPushConsumer().getDefaultMQPushConsumerImpl().getConsumeMessageService(); List msgExtList = new ArrayList<>(msgs.size()); - for(Message msg : msgs){ + for (Message msg : msgs) { msgExtList.add(OMSUtil.msgConvertExt(msg)); } ((ConsumeMessageConcurrentlyService) consumeMessageService).updateOffset(msgExtList, (EventMeshConsumeConcurrentlyContext) context); diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/domain/ConsumeRequest.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/domain/ConsumeRequest.java similarity index 94% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/domain/ConsumeRequest.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/domain/ConsumeRequest.java index 7aefcdae73..2bcb32887b 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/domain/ConsumeRequest.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/domain/ConsumeRequest.java @@ -14,7 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.domain; + +package org.apache.eventmesh.connector.rocketmq.domain; import org.apache.rocketmq.client.impl.consumer.ProcessQueue; import org.apache.rocketmq.common.message.MessageExt; @@ -27,7 +28,7 @@ public class ConsumeRequest { private long startConsumeTimeMillis; public ConsumeRequest(final MessageExt messageExt, final MessageQueue messageQueue, - final ProcessQueue processQueue) { + final ProcessQueue processQueue) { this.messageExt = messageExt; this.messageQueue = messageQueue; this.processQueue = processQueue; diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/domain/NonStandardKeys.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/domain/NonStandardKeys.java similarity index 96% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/domain/NonStandardKeys.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/domain/NonStandardKeys.java index 453c1eca51..5264d785e0 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/domain/NonStandardKeys.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/domain/NonStandardKeys.java @@ -14,7 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.domain; + +package org.apache.eventmesh.connector.rocketmq.domain; public interface NonStandardKeys { String CONSUMER_GROUP = "rmq.consumer.group"; diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/domain/RocketMQConstants.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/domain/RocketMQConstants.java similarity index 94% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/domain/RocketMQConstants.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/domain/RocketMQConstants.java index 181f89b0e2..063f0f36fc 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/domain/RocketMQConstants.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/domain/RocketMQConstants.java @@ -14,7 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.domain; + +package org.apache.eventmesh.connector.rocketmq.domain; public interface RocketMQConstants { diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/patch/EventMeshConsumeConcurrentlyContext.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/patch/EventMeshConsumeConcurrentlyContext.java similarity index 93% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/patch/EventMeshConsumeConcurrentlyContext.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/patch/EventMeshConsumeConcurrentlyContext.java index f0af34ad2a..05442a6ab2 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/patch/EventMeshConsumeConcurrentlyContext.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/patch/EventMeshConsumeConcurrentlyContext.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.patch; +package org.apache.eventmesh.connector.rocketmq.patch; -import com.webank.eventmesh.api.AbstractContext; +import org.apache.eventmesh.api.AbstractContext; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; import org.apache.rocketmq.client.impl.consumer.ProcessQueue; import org.apache.rocketmq.common.message.MessageQueue; diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/patch/EventMeshConsumeConcurrentlyStatus.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/patch/EventMeshConsumeConcurrentlyStatus.java similarity index 95% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/patch/EventMeshConsumeConcurrentlyStatus.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/patch/EventMeshConsumeConcurrentlyStatus.java index 2b505b00c0..468b14f568 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/patch/EventMeshConsumeConcurrentlyStatus.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/patch/EventMeshConsumeConcurrentlyStatus.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.patch; +package org.apache.eventmesh.connector.rocketmq.patch; public enum EventMeshConsumeConcurrentlyStatus { /** diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/patch/EventMeshMessageListenerConcurrently.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/patch/EventMeshMessageListenerConcurrently.java similarity index 98% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/patch/EventMeshMessageListenerConcurrently.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/patch/EventMeshMessageListenerConcurrently.java index 854fa04a65..47e8ee11be 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/patch/EventMeshMessageListenerConcurrently.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/patch/EventMeshMessageListenerConcurrently.java @@ -15,7 +15,9 @@ * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.patch; +package org.apache.eventmesh.connector.rocketmq.patch; + +import java.util.List; import org.apache.commons.collections4.CollectionUtils; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; @@ -25,8 +27,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; - public abstract class EventMeshMessageListenerConcurrently implements MessageListenerConcurrently { private static final Logger LOG = LoggerFactory.getLogger(EventMeshMessageListenerConcurrently.class); diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/producer/AbstractOMSProducer.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractOMSProducer.java similarity index 87% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/producer/AbstractOMSProducer.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractOMSProducer.java index b47587f44a..548077a4ec 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/producer/AbstractOMSProducer.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractOMSProducer.java @@ -14,14 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.producer; -import com.webank.eventmesh.connector.rocketmq.utils.BeanUtils; -import com.webank.eventmesh.connector.rocketmq.utils.OMSUtil; -import com.webank.eventmesh.connector.rocketmq.config.ClientConfig; -import io.openmessaging.api.exception.OMSRuntimeException; +package org.apache.eventmesh.connector.rocketmq.producer; + +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.connector.rocketmq.config.ClientConfig; +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; @@ -33,16 +38,13 @@ import org.apache.rocketmq.remoting.exception.RemotingTimeoutException; import org.apache.rocketmq.remoting.protocol.LanguageCode; -import java.util.Properties; -import java.util.concurrent.atomic.AtomicBoolean; - public abstract class AbstractOMSProducer { final static InternalLogger log = ClientLogger.getLog(); final Properties properties; final DefaultMQProducer rocketmqProducer; protected final AtomicBoolean started = new AtomicBoolean(false); -// private boolean started = false; + // private boolean started = false; private final ClientConfig clientConfig; private final String PRODUCER_ID = "PRODUCER_ID"; @@ -99,20 +101,20 @@ OMSRuntimeException checkProducerException(String topic, String msgId, Throwable 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", - this.rocketmqProducer.getSendMsgTimeout(), topic, msgId), e); + this.rocketmqProducer.getSendMsgTimeout(), topic, msgId), e); } 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", - topic, msgId, brokerException.getErrorMessage()), e); + topic, msgId, brokerException.getErrorMessage()), e); } if (e.getCause() instanceof RemotingConnectException) { - RemotingConnectException connectException = (RemotingConnectException)e.getCause(); + 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); + String.format("Network connection experiences failures. Topic=%s, msgId=%s, %s", + topic, msgId, connectException.getMessage()), + e); } } } @@ -121,10 +123,10 @@ OMSRuntimeException checkProducerException(String topic, String msgId, Throwable MQClientException clientException = (MQClientException) e; if (-1 == clientException.getResponseCode()) { return new OMSRuntimeException(-1, String.format("Topic does not exist, Topic=%s, msgId=%s", - topic, msgId), e); + 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", - topic, msgId), e); + topic, msgId), e); } } } @@ -132,7 +134,7 @@ OMSRuntimeException checkProducerException(String topic, String msgId, Throwable } protected void checkProducerServiceState(DefaultMQProducerImpl producer) { - switch(producer.getServiceState()) { + switch (producer.getServiceState()) { case CREATE_JUST: throw new OMSRuntimeException(String.format("You do not have start the producer, %s", producer.getServiceState())); case SHUTDOWN_ALREADY: diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/producer/ProducerImpl.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/ProducerImpl.java similarity index 93% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/producer/ProducerImpl.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/ProducerImpl.java index 89591df066..f8d4302d02 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/producer/ProducerImpl.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/ProducerImpl.java @@ -14,16 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.producer; -import com.webank.eventmesh.connector.rocketmq.utils.OMSUtil; -import io.openmessaging.api.*; -import io.openmessaging.api.exception.OMSRuntimeException; -import org.apache.rocketmq.common.message.MessageClientIDSetter; +package org.apache.eventmesh.connector.rocketmq.producer; import java.util.Properties; import java.util.concurrent.ExecutorService; +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.connector.rocketmq.utils.OMSUtil; +import org.apache.rocketmq.common.message.MessageClientIDSetter; public class ProducerImpl extends AbstractOMSProducer implements Producer { @@ -38,7 +44,7 @@ public Properties attributes() { return properties; } - public void setExtFields(){ + public void setExtFields() { super.getRocketmqProducer().setRetryTimesWhenSendFailed(0); super.getRocketmqProducer().setRetryTimesWhenSendAsyncFailed(0); super.getRocketmqProducer().setPollNameServerInterval(60000); diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java similarity index 88% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java index 061854574f..6364650035 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java @@ -15,31 +15,38 @@ * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.producer; - -import com.webank.eventmesh.api.RRCallback; -import com.webank.eventmesh.api.producer.MeshMQProducer; -import com.webank.eventmesh.connector.rocketmq.common.EventMeshConstants; -import com.webank.eventmesh.connector.rocketmq.config.ClientConfiguration; -import com.webank.eventmesh.connector.rocketmq.config.ConfigurationWraper; -import io.openmessaging.api.*; +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.common.EventMeshConstants; +import org.apache.eventmesh.connector.rocketmq.config.ClientConfiguration; +import org.apache.eventmesh.connector.rocketmq.config.ConfigurationWraper; import org.apache.rocketmq.client.exception.MQBrokerException; import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.remoting.exception.RemotingException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.util.Properties; -import java.util.concurrent.ExecutorService; - public class RocketMQProducerImpl implements MeshMQProducer { public Logger logger = LoggerFactory.getLogger(this.getClass()); private ProducerImpl producer; - public final String DEFAULT_ACCESS_DRIVER = "com.webank.eventmesh.connector.rocketmq.MessagingAccessPointImpl"; + public final String DEFAULT_ACCESS_DRIVER = "org.apache.eventmesh.connector.rocketmq.MessagingAccessPointImpl"; @Override public synchronized void init(Properties keyValue) { diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/promise/DefaultPromise.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/promise/DefaultPromise.java similarity index 98% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/promise/DefaultPromise.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/promise/DefaultPromise.java index 8469db4705..cc30eb5ab0 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/promise/DefaultPromise.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/promise/DefaultPromise.java @@ -14,17 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.promise; + +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; -import java.util.ArrayList; -import java.util.List; - public class DefaultPromise implements Future { private static final InternalLogger LOG = InternalLoggerFactory.getLogger(DefaultPromise.class); private final Object lock = new Object(); @@ -105,7 +107,7 @@ public V get(final long timeout) { } public boolean set(final V value) { - if (value == null){ + if (value == null) { return false; } this.result = value; @@ -113,7 +115,7 @@ public boolean set(final V value) { } public boolean setFailure(final Throwable cause) { - if (cause == null){ + if (cause == null) { return false; } this.exception = cause; diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/promise/FutureState.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/promise/FutureState.java similarity index 95% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/promise/FutureState.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/promise/FutureState.java index 9903953a5c..1f364a89fc 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/promise/FutureState.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/promise/FutureState.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.promise; +package org.apache.eventmesh.connector.rocketmq.promise; public enum FutureState { /** diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/utils/BeanUtils.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/BeanUtils.java similarity index 96% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/utils/BeanUtils.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/BeanUtils.java index e55c336e55..0aae801dcf 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/utils/BeanUtils.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/BeanUtils.java @@ -14,11 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.utils; -import org.apache.commons.lang3.StringUtils; -import org.apache.rocketmq.client.log.ClientLogger; -import org.apache.rocketmq.logging.InternalLogger; +package org.apache.eventmesh.connector.rocketmq.utils; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -27,6 +24,10 @@ import java.util.Properties; import java.util.Set; +import org.apache.commons.lang3.StringUtils; +import org.apache.rocketmq.client.log.ClientLogger; +import org.apache.rocketmq.logging.InternalLogger; + public final class BeanUtils { final static InternalLogger log = ClientLogger.getLog(); @@ -78,9 +79,9 @@ public final class BeanUtils { * to have more than one setter method (with different argument * signatures) for the same property.

* - * @param clazz JavaBean class whose properties are being populated + * @param clazz JavaBean class whose properties are being populated * @param properties Map keyed by property name, with the corresponding (String or String[]) value(s) to be set - * @param Class type + * @param Class type * @return Class instance */ public static T populate(final Properties properties, final Class clazz) { @@ -116,7 +117,7 @@ public static Class getMethodClass(Class clazz, String methodName) { } public static void setProperties(Class clazz, Object obj, String methodName, - Object value) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Object value) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Class parameterClass = getMethodClass(clazz, methodName); Method setterMethod = clazz.getMethod(methodName, parameterClass); if (parameterClass == Boolean.TYPE) { diff --git a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/utils/OMSUtil.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/OMSUtil.java similarity index 96% rename from eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/utils/OMSUtil.java rename to eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/OMSUtil.java index d087acc3cb..ba35acf186 100644 --- a/eventmesh-connector-rocketmq/src/main/java/com/webank/eventmesh/connector/rocketmq/utils/OMSUtil.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/OMSUtil.java @@ -14,20 +14,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.connector.rocketmq.utils; -import com.webank.eventmesh.common.Constants; +package org.apache.eventmesh.connector.rocketmq.utils; + +import java.lang.reflect.Field; +import java.util.Iterator; +import java.util.Map; +import java.util.NoSuchElementException; +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; import org.apache.rocketmq.common.message.MessageAccessor; import org.apache.rocketmq.common.message.MessageExt; -import java.lang.reflect.Field; -import java.util.*; - public class OMSUtil { /** @@ -178,8 +184,8 @@ public static org.apache.rocketmq.common.message.MessageExt msgConvertExt(Messag //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); + 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); diff --git a/eventmesh-connector-rocketmq/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java b/eventmesh-connector-rocketmq/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java index b2d116dbd0..95c2fc9655 100644 --- a/eventmesh-connector-rocketmq/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java +++ b/eventmesh-connector-rocketmq/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java @@ -14,9 +14,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.rocketmq.client.impl.consumer; -import com.webank.eventmesh.connector.rocketmq.patch.EventMeshConsumeConcurrentlyContext; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import org.apache.eventmesh.connector.rocketmq.patch.EventMeshConsumeConcurrentlyContext; import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; @@ -36,9 +51,6 @@ import org.apache.rocketmq.logging.InternalLogger; import org.apache.rocketmq.remoting.common.RemotingHelper; -import java.util.*; -import java.util.concurrent.*; - public class ConsumeMessageConcurrentlyService implements ConsumeMessageService { private static final InternalLogger log = ClientLogger.getLog(); private final DefaultMQPushConsumerImpl defaultMQPushConsumerImpl; @@ -342,7 +354,7 @@ public void updateOffset(List msgs, ConsumeConcurrentlyContext conte log.debug("update offset, msg: {} {} {}", m.getTopic(), m.getQueueId(), m.getQueueOffset()); } MessageQueue messageQueue = context.getMessageQueue(); - ProcessQueue processQueue = ((EventMeshConsumeConcurrentlyContext)context).getProcessQueue(); + ProcessQueue processQueue = ((EventMeshConsumeConcurrentlyContext) context).getProcessQueue(); long offset = processQueue.removeMessage(msgs); if (offset >= 0) { log.debug("update offset={}", offset); @@ -464,6 +476,8 @@ public void run() { for (MessageExt msg : msgs) { MessageAccessor.setConsumeStartTimeStamp(msg, String.valueOf(System.currentTimeMillis())); } + + } status = listener.consumeMessage(Collections.unmodifiableList(msgs), context); } catch (Throwable e) { diff --git a/eventmesh-connector-rocketmq/src/main/resources/META-INF/services/com.webank.eventmesh.api.consumer.MeshMQPushConsumer b/eventmesh-connector-rocketmq/src/main/resources/META-INF/services/com.webank.eventmesh.api.consumer.MeshMQPushConsumer deleted file mode 100644 index 8e4788c49e..0000000000 --- a/eventmesh-connector-rocketmq/src/main/resources/META-INF/services/com.webank.eventmesh.api.consumer.MeshMQPushConsumer +++ /dev/null @@ -1 +0,0 @@ -com.webank.eventmesh.connector.rocketmq.consumer.RocketMQConsumerImpl \ No newline at end of file diff --git a/eventmesh-connector-rocketmq/src/main/resources/META-INF/services/com.webank.eventmesh.api.producer.MeshMQProducer b/eventmesh-connector-rocketmq/src/main/resources/META-INF/services/com.webank.eventmesh.api.producer.MeshMQProducer deleted file mode 100644 index 6fcd066b38..0000000000 --- a/eventmesh-connector-rocketmq/src/main/resources/META-INF/services/com.webank.eventmesh.api.producer.MeshMQProducer +++ /dev/null @@ -1 +0,0 @@ -com.webank.eventmesh.connector.rocketmq.producer.RocketMQProducerImpl \ No newline at end of file diff --git a/eventmesh-connector-rocketmq/src/main/resources/META-INF/services/org.apache.eventmesh.api.consumer.MeshMQPushConsumer b/eventmesh-connector-rocketmq/src/main/resources/META-INF/services/org.apache.eventmesh.api.consumer.MeshMQPushConsumer new file mode 100644 index 0000000000..c98880a841 --- /dev/null +++ b/eventmesh-connector-rocketmq/src/main/resources/META-INF/services/org.apache.eventmesh.api.consumer.MeshMQPushConsumer @@ -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. + +org.apache.eventmesh.connector.rocketmq.consumer.RocketMQConsumerImpl \ No newline at end of file diff --git a/eventmesh-connector-rocketmq/src/main/resources/META-INF/services/org.apache.eventmesh.api.producer.MeshMQProducer b/eventmesh-connector-rocketmq/src/main/resources/META-INF/services/org.apache.eventmesh.api.producer.MeshMQProducer new file mode 100644 index 0000000000..28907ca176 --- /dev/null +++ b/eventmesh-connector-rocketmq/src/main/resources/META-INF/services/org.apache.eventmesh.api.producer.MeshMQProducer @@ -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. + +org.apache.eventmesh.connector.rocketmq.producer.RocketMQProducerImpl \ No newline at end of file diff --git a/eventmesh-connector-rocketmq/src/test/java/rocketmq/consumer/PushConsumerImplTest.java b/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/consumer/PushConsumerImplTest.java similarity index 66% rename from eventmesh-connector-rocketmq/src/test/java/rocketmq/consumer/PushConsumerImplTest.java rename to eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/consumer/PushConsumerImplTest.java index 630cdad03b..186ef4a529 100644 --- a/eventmesh-connector-rocketmq/src/test/java/rocketmq/consumer/PushConsumerImplTest.java +++ b/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/consumer/PushConsumerImplTest.java @@ -14,27 +14,37 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package rocketmq.consumer; -import com.webank.eventmesh.connector.rocketmq.consumer.PushConsumerImpl; -import com.webank.eventmesh.connector.rocketmq.domain.NonStandardKeys; -import io.openmessaging.api.*; +package org.apache.rocketmq.consumer; + +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.Action; +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.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 org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; -import java.lang.reflect.Field; -import java.util.Collections; -import java.util.Properties; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; - @RunWith(MockitoJUnitRunner.class) public class PushConsumerImplTest { private Consumer consumer; @@ -43,25 +53,37 @@ public class PushConsumerImplTest { private DefaultMQPushConsumer rocketmqPushConsumer; @Before - public void init() throws NoSuchFieldException, IllegalAccessException { - - final MessagingAccessPoint messagingAccessPoint = OMS.builder().endpoint("oms:rocketmq://IP1:9876,IP2:9876/namespace").build(); + public void before() throws Exception { Properties consumerProp = new Properties(); + 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); + + consumerProp.setProperty("message.model", "CLUSTERING"); + + //Properties consumerProp = new Properties(); consumerProp.put("CONSUMER_ID", "TestGroup"); consumer = messagingAccessPoint.createConsumer(consumerProp); + Field field = PushConsumerImpl.class.getDeclaredField("rocketmqPushConsumer"); field.setAccessible(true); DefaultMQPushConsumer innerConsumer = (DefaultMQPushConsumer) field.get(consumer); field.set(consumer, rocketmqPushConsumer); //Replace - when(rocketmqPushConsumer.getMessageListener()).thenReturn(innerConsumer.getMessageListener()); + Mockito.when(rocketmqPushConsumer.getMessageListener()).thenReturn(innerConsumer.getMessageListener()); consumer.start(); } + @After + public void after() throws Exception { + Mockito.verify(rocketmqPushConsumer).getMessageListener(); + consumer.shutdown(); + } + @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"); @@ -77,6 +99,8 @@ public void consume(Message message, AsyncConsumeContext context) { } }); ((MessageListenerConcurrently) rocketmqPushConsumer - .getMessageListener()).consumeMessage(Collections.singletonList(consumedMsg), null); + .getMessageListener()).consumeMessage(Collections.singletonList(consumedMsg), null); + + } } \ No newline at end of file diff --git a/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/producer/ProducerImplTest.java b/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/producer/ProducerImplTest.java new file mode 100644 index 0000000000..83d55710f0 --- /dev/null +++ b/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/producer/ProducerImplTest.java @@ -0,0 +1,153 @@ +/* + * Licensed 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.rocketmq.producer; + +import static org.assertj.core.api.Assertions.assertThat; +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.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; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.apache.rocketmq.client.producer.SendResult; +import org.apache.rocketmq.client.producer.SendStatus; +import org.apache.rocketmq.common.ServiceState; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.common.message.MessageQueue; +import org.apache.rocketmq.remoting.exception.RemotingException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class ProducerImplTest { + private Producer producer; + + @Mock + private DefaultMQProducer rocketmqProducer; + + @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); + + Field field = AbstractOMSProducer.class.getDeclaredField("rocketmqProducer"); + field.setAccessible(true); + field.set(producer, rocketmqProducer); + +// messagingAccessPoint.startup(); + producer.start(); + + } + + + @After + public void after() throws NoSuchFieldException, IllegalAccessException { + + producer.shutdown(); + + } + + @Test + public void testSend_OK() throws InterruptedException, RemotingException, MQClientException, MQBrokerException { + SendResult sendResult = new SendResult(); + sendResult.setMsgId("TestMsgID"); + sendResult.setSendStatus(SendStatus.SEND_OK); + MessageQueue messageQueue = new MessageQueue("HELLO_TOPIC", "testBroker", 0); + sendResult.setMessageQueue(messageQueue); + + Mockito.when(rocketmqProducer.send(any(Message.class))).thenReturn(sendResult); + + DefaultMQProducer defaultMQProducer = new DefaultMQProducer("testGroup"); + DefaultMQProducerImpl defaultMQProducerImpl = new DefaultMQProducerImpl(defaultMQProducer); + defaultMQProducerImpl.setServiceState(ServiceState.RUNNING); + 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); + + assertThat(omsResult.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"); + DefaultMQProducerImpl defaultMQProducerImpl = new DefaultMQProducerImpl(defaultMQProducer); + defaultMQProducerImpl.setServiceState(ServiceState.RUNNING); + Mockito.when(rocketmqProducer.getDefaultMQProducerImpl()).thenReturn(defaultMQProducerImpl); + MQClientException exception = new MQClientException("Send message to RocketMQ broker failed.", new Exception()); + 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); + } catch (Exception e) { + assertThat(e).hasMessageContaining("Send message to RocketMQ broker failed."); + } + + Mockito.verify(rocketmqProducer).send(any(Message.class)); + } + +} \ No newline at end of file diff --git a/eventmesh-connector-rocketmq/src/test/java/rocketmq/promise/DefaultPromiseTest.java b/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/promise/DefaultPromiseTest.java similarity index 98% rename from eventmesh-connector-rocketmq/src/test/java/rocketmq/promise/DefaultPromiseTest.java rename to eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/promise/DefaultPromiseTest.java index 825ee7986e..3d4c8c2ab3 100644 --- a/eventmesh-connector-rocketmq/src/test/java/rocketmq/promise/DefaultPromiseTest.java +++ b/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/promise/DefaultPromiseTest.java @@ -16,7 +16,7 @@ // */ //package rocketmq.promise; // -//import com.webank.eventmesh.connector.rocketmq.promise.DefaultPromise; +//import org.apache.eventmesh.connector.rocketmq.promise.DefaultPromise; //import io.openmessaging.Future; //import io.openmessaging.FutureListener; //import io.openmessaging.Promise; diff --git a/eventmesh-connector-rocketmq/src/test/java/rocketmq/utils/BeanUtilsTest.java b/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/utils/BeanUtilsTest.java similarity index 92% rename from eventmesh-connector-rocketmq/src/test/java/rocketmq/utils/BeanUtilsTest.java rename to eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/utils/BeanUtilsTest.java index b5a221ed91..7f545f3c0b 100644 --- a/eventmesh-connector-rocketmq/src/test/java/rocketmq/utils/BeanUtilsTest.java +++ b/eventmesh-connector-rocketmq/src/test/java/org/apache/rocketmq/utils/BeanUtilsTest.java @@ -14,17 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package rocketmq.utils; -import com.webank.eventmesh.connector.rocketmq.config.ClientConfig; -import com.webank.eventmesh.connector.rocketmq.domain.NonStandardKeys; -import com.webank.eventmesh.connector.rocketmq.utils.BeanUtils; +package org.apache.rocketmq.utils; + +import java.util.Properties; + +import org.apache.eventmesh.connector.rocketmq.config.ClientConfig; +import org.apache.eventmesh.connector.rocketmq.domain.NonStandardKeys; +import org.apache.eventmesh.connector.rocketmq.utils.BeanUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.Properties; - public class BeanUtilsTest { private Properties properties = new Properties(); @@ -62,12 +63,12 @@ public void setLongTest(final long longTest) { this.longTest = longTest; } - CustomizedConfig() { + public CustomizedConfig() { } } @Before - public void init() { + public void before() { properties.put(NonStandardKeys.MAX_REDELIVERY_TIMES, 120); properties.put(CustomizedConfig.STRING_TEST, "kaka"); properties.put(NonStandardKeys.CONSUMER_GROUP, "Default_Consumer_Group"); diff --git a/eventmesh-connector-rocketmq/src/test/java/rocketmq/producer/ProducerImplTest.java b/eventmesh-connector-rocketmq/src/test/java/rocketmq/producer/ProducerImplTest.java deleted file mode 100644 index b053213d14..0000000000 --- a/eventmesh-connector-rocketmq/src/test/java/rocketmq/producer/ProducerImplTest.java +++ /dev/null @@ -1,106 +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 rocketmq.producer; - -import com.webank.eventmesh.connector.rocketmq.producer.AbstractOMSProducer; -import io.openmessaging.api.OMS; -import io.openmessaging.api.MessagingAccessPoint; -import io.openmessaging.api.Producer; -import io.openmessaging.api.exception.OMSRuntimeException; -import org.apache.rocketmq.client.exception.MQBrokerException; -import org.apache.rocketmq.client.exception.MQClientException; -import org.apache.rocketmq.client.producer.DefaultMQProducer; -import org.apache.rocketmq.client.producer.SendResult; -import org.apache.rocketmq.client.producer.SendStatus; -import org.apache.rocketmq.common.message.Message; -import org.apache.rocketmq.remoting.exception.RemotingException; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - -import java.lang.reflect.Field; -import java.util.Properties; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Fail.failBecauseExceptionWasNotThrown; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.when; - -@RunWith(MockitoJUnitRunner.class) -public class ProducerImplTest { - private Producer producer; - - @Mock - private DefaultMQProducer rocketmqProducer; - - @Before - public void init() throws NoSuchFieldException, IllegalAccessException { - final MessagingAccessPoint messagingAccessPoint = OMS.builder().endpoint("oms:rocketmq://IP1:9876,IP2:9876/namespace").build(); - producer = messagingAccessPoint.createProducer(new Properties()); - - Field field = AbstractOMSProducer.class.getDeclaredField("rocketmqProducer"); - field.setAccessible(true); - field.set(producer, rocketmqProducer); - -// messagingAccessPoint.startup(); - producer.start(); - } - - @Test - public void testSend_OK() throws InterruptedException, RemotingException, MQClientException, MQBrokerException { - SendResult sendResult = new SendResult(); - sendResult.setMsgId("TestMsgID"); - sendResult.setSendStatus(SendStatus.SEND_OK); - when(rocketmqProducer.send(any(Message.class), anyLong())).thenReturn(sendResult); - io.openmessaging.api.Message message = new io.openmessaging.api.Message("HELLO_TOPIC", "", new byte[] {'a'}); - io.openmessaging.api.SendResult omsResult = - producer.send(message); - - assertThat(omsResult.getMessageId()).isEqualTo("TestMsgID"); - } - - @Test - public void testSend_Not_OK() throws InterruptedException, RemotingException, MQClientException, MQBrokerException { - SendResult sendResult = new SendResult(); - sendResult.setSendStatus(SendStatus.FLUSH_DISK_TIMEOUT); - - when(rocketmqProducer.send(any(Message.class), anyLong())).thenReturn(sendResult); - 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 { - when(rocketmqProducer.send(any(Message.class), anyLong())).thenThrow(MQClientException.class); - 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."); - } - } - -} \ No newline at end of file diff --git a/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/io.openmessaging.MessagingAccessPoint b/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/io.openmessaging.MessagingAccessPoint deleted file mode 100644 index 9174f1a18a..0000000000 --- a/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/io.openmessaging.MessagingAccessPoint +++ /dev/null @@ -1 +0,0 @@ -com.webank.eventmesh.connector.rocketmq.MessagingAccessPointImpl \ No newline at end of file diff --git a/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/io.openmessaging.producer.Producer b/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/io.openmessaging.producer.Producer deleted file mode 100644 index 7cfe963b5f..0000000000 --- a/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/io.openmessaging.producer.Producer +++ /dev/null @@ -1 +0,0 @@ -com.webank.eventmesh.connector.rocketmq.producer.ProducerImpl \ No newline at end of file diff --git a/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/org.apache.io.openmessaging.MessagingAccessPoint b/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/org.apache.io.openmessaging.MessagingAccessPoint new file mode 100644 index 0000000000..7347e69999 --- /dev/null +++ b/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/org.apache.io.openmessaging.MessagingAccessPoint @@ -0,0 +1 @@ +org.apache.eventmesh.connector.rocketmq.MessagingAccessPointImpl \ No newline at end of file diff --git a/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/org.apache.io.openmessaging.producer.Producer b/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/org.apache.io.openmessaging.producer.Producer new file mode 100644 index 0000000000..5ea8a1853f --- /dev/null +++ b/eventmesh-connector-rocketmq/src/test/resources/META-INF/services/org.apache.io.openmessaging.producer.Producer @@ -0,0 +1 @@ +org.apache.eventmesh.connector.rocketmq.producer.ProducerImpl \ No newline at end of file diff --git a/eventmesh-runtime/bin/start.sh b/eventmesh-runtime/bin/start.sh index a0654e47f3..9c0724bdd0 100644 --- a/eventmesh-runtime/bin/start.sh +++ b/eventmesh-runtime/bin/start.sh @@ -1,4 +1,21 @@ #!/bin/sh +# +# 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. # Copyright (C) @2017 Webank Group Holding Limited @@ -38,7 +55,7 @@ function is_java8 { #0(not running), 1(is running) #function is_proxyRunning { # local _pid="$1" -# local pid=`ps ax | grep -i 'com.webank.runtime.boot.EventMeshStartup' |grep java | grep -v grep | awk '{print $1}'|grep $_pid` +# local pid=`ps ax | grep -i 'org.apache.eventmesh.runtime.boot.EventMeshStartup' |grep java | grep -v grep | awk '{print $1}'|grep $_pid` # if [ -z "$pid" ] ; then # return 0 # else @@ -53,13 +70,13 @@ function get_pid { else if [[ $OS =~ Msys ]]; then # 在Msys上存在可能无法kill识别出的进程的BUG - ppid=`jps -v | grep -i "com.webank.eventmesh.runtime.boot.EventMeshStartup" | grep java | grep -v grep | awk -F ' ' {'print $1'}` + ppid=`jps -v | grep -i "org.apache.eventmesh.runtime.boot.EventMeshStartup" | grep java | grep -v grep | awk -F ' ' {'print $1'}` elif [[ $OS =~ Darwin ]]; then # 已知问题:grep java 可能无法精确识别java进程 - ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "com.webank.eventmesh.runtime.boot.EventMeshStartup" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "org.apache.eventmesh.runtime.boot.EventMeshStartup" | grep -Ev "^root" |awk -F ' ' {'print $2'}) else #在Linux服务器上要求尽可能精确识别进程 - ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_HOME | grep -i "com.webank.eventmesh.runtime.boot.EventMeshStartup" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_HOME | grep -i "org.apache.eventmesh.runtime.boot.EventMeshStartup" | grep -Ev "^root" |awk -F ' ' {'print $2'}) fi fi echo "$ppid"; @@ -154,7 +171,7 @@ make_logs_dir echo "using jdk[$JAVA]" >> ${EVENTMESH_LOG_HOME}/eventmesh.out -EVENTMESH_MAIN=com.webank.eventmesh.runtime.boot.EventMeshStartup +EVENTMESH_MAIN=org.apache.eventmesh.runtime.boot.EventMeshStartup if [ $DOCKER ] then $JAVA $JAVA_OPT -classpath ${EVENTMESH_HOME}/conf:${EVENTMESH_HOME}/apps/*:${EVENTMESH_HOME}/lib/* $EVENTMESH_MAIN >> ${EVENTMESH_LOG_HOME}/eventmesh.out diff --git a/eventmesh-runtime/bin/stop.sh b/eventmesh-runtime/bin/stop.sh index 42e653c02a..4897c77612 100644 --- a/eventmesh-runtime/bin/stop.sh +++ b/eventmesh-runtime/bin/stop.sh @@ -1,4 +1,21 @@ #!/bin/sh +# +# 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. #detect operating system. OS=$(uname -o) @@ -14,13 +31,13 @@ function get_pid { else if [[ $OS =~ Msys ]]; then # 在Msys上存在可能无法kill识别出的进程的BUG - ppid=`jps -v | grep -i "com.webank.runtime.boot.EventMeshStartup" | grep java | grep -v grep | awk -F ' ' {'print $1'}` + ppid=`jps -v | grep -i "org.apache.eventmesh.runtime.boot.EventMeshStartup" | grep java | grep -v grep | awk -F ' ' {'print $1'}` elif [[ $OS =~ Darwin ]]; then # 已知问题:grep java 可能无法精确识别java进程 - ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "com.webank.runtime.boot.EventMeshStartup" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "org.apache.eventmesh.runtime.boot.EventMeshStartup" | grep -Ev "^root" |awk -F ' ' {'print $2'}) else #在Linux服务器上要求尽可能精确识别进程 - ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_HOME | grep -i "com.webank.runtime.boot.EventMeshStartup" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_HOME | grep -i "org.apache.eventmesh.runtime.boot.EventMeshStartup" | grep -Ev "^root" |awk -F ' ' {'print $2'}) fi fi echo "$ppid"; diff --git a/eventmesh-runtime/bin/watchdog.sh b/eventmesh-runtime/bin/watchdog.sh index 0d0d62020d..9708e3b918 100644 --- a/eventmesh-runtime/bin/watchdog.sh +++ b/eventmesh-runtime/bin/watchdog.sh @@ -1,4 +1,21 @@ #!/bin/bash +# +# 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. set -e; function usage(){ diff --git a/eventmesh-runtime/build.gradle b/eventmesh-runtime/build.gradle index 9619b5ec4d..09dd79f9c2 100644 --- a/eventmesh-runtime/build.gradle +++ b/eventmesh-runtime/build.gradle @@ -14,150 +14,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import java.util.concurrent.TimeUnit - -apply plugin: 'java' -apply plugin: "maven" -apply plugin: "eclipse" -apply plugin: "idea" - sourceCompatibility = 1.8 -repositories { - mavenLocal() - maven { - url "https://maven.aliyun.com/repository/public" - } - mavenCentral() -} - -//List defibus = [ -// "com.webank.defibus:defibus-client:$defibus_version", -// "com.webank.defibus:defibus-common:$defibus_version" -//] - -List junit = [ - "junit:junit:4.12" -] - -List log4j2 = [ - "org.apache.logging.log4j:log4j-api:2.13.3", - "org.apache.logging.log4j:log4j-core:2.13.3", - "org.apache.logging.log4j:log4j-slf4j-impl:2.13.3", - "org.apache.logging.log4j:log4j-web:2.13.3", - "com.lmax:disruptor:3.4.2" +List metrics = [ + "io.dropwizard.metrics:metrics-core:4.1.0", + "io.dropwizard.metrics:metrics-healthchecks:4.1.0", + "io.dropwizard.metrics:metrics-annotation:4.1.0", + "io.dropwizard.metrics:metrics-json:4.1.0" ] -List sl4j = [ - "org.slf4j:slf4j-api:1.7.30" -] -List metrics = [ - "io.dropwizard.metrics:metrics-core:4.1.0", - "io.dropwizard.metrics:metrics-healthchecks:4.1.0", - "io.dropwizard.metrics:metrics-annotation:4.1.0", - "io.dropwizard.metrics:metrics-json:4.1.0" -] -List apache_common = [ - "org.apache.commons:commons-text:1.9" +List open_message = [ + "io.openmessaging:openmessaging-api:2.2.1-pubsub" ] dependencies { - compile project(":eventmesh-connector-api"),apache_common,metrics, log4j2, sl4j - testCompile project(":eventmesh-connector-api"),apache_common,metrics, log4j2, sl4j, junit -} - -clean.doFirst { - delete 'build' - delete 'dist' -} - -def versionString = project.version -if (project.findProperty("buildNo") instanceof String) { - versionString = project.version + '_' + project.property("buildNo") + implementation metrics, open_message,project(":eventmesh-connector-api"),project(":eventmesh-common") + testImplementation metrics,open_message,project(":eventmesh-common"),project(":eventmesh-connector-api") } - -task zip(type: Zip, dependsOn: ['clean', 'jar']) { - extension = 'zip' - archiveName = project.name + '_' + versionString + '.' + extension - destinationDir = new File(projectDir, 'dist') - - into('apps') { - from project.jar.getArchivePath() - } - - into('bin') { - from 'bin' - } - - into('conf') { - from "conf" - } - - into('lib') { - from project.configurations.runtime - exclude '**/*.properties*' - exclude '**/*testng*.jar' - exclude '**/*powermock*.jar' - exclude '**/*mockito*.jar' - exclude '**/*junit*.jar' - exclude '**/*jacoco*.jar' - exclude '**/*log4j2.xml*' - exclude '**/spring-boot-devtools*.jar' - } - - into('scripts') { - from "scripts" - } -} - -task tar(type: Tar, dependsOn: ['clean', 'jar']) { - extension = 'tar.gz' - compression = Compression.GZIP - archiveName = project.name + '_' + versionString + '.' + extension - destinationDir = new File(projectDir, 'dist') - - into('apps') { - from project.jar.getArchivePath() - } - - into('bin') { - from 'bin' - } - - into('conf') { - from "conf" - } - - into('lib') { - from project.configurations.runtime - exclude '**/*.properties*' - exclude '**/*testng*.jar' - exclude '**/*powermock*.jar' - exclude '**/*mockito*.jar' - exclude '**/*junit*.jar' - exclude '**/*jacoco*.jar' - exclude '**/*log4j2.xml*' - exclude '**/spring-boot-devtools*.jar' - } - - into('scripts') { - from "scripts" - } -} - -uploadArchives { - repositories { - mavenDeployer { - snapshotRepository(url: 'Your target repo address') { - authentication(userName: 'Your user name', password: 'Your password') - } - repository(url: 'Your target repo address') { - authentication(userName: 'Your user name', password: 'Your password') - } - } - } -} \ No newline at end of file diff --git a/eventmesh-runtime/conf/eventmesh.properties b/eventmesh-runtime/conf/eventmesh.properties index 198080291c..21b9bb76e7 100644 --- a/eventmesh-runtime/conf/eventmesh.properties +++ b/eventmesh-runtime/conf/eventmesh.properties @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - ###############################EVNETMESH-runtime ENV################################# eventMesh.server.idc=DEFAULT eventMesh.server.env=PRD @@ -24,7 +23,6 @@ eventMesh.server.name=EVENTMESH-runtime eventMesh.server.dcn=010 eventMesh.sysid=0000 eventMesh.server.http.port=10105 - ########################## eventMesh tcp configuration ############################ eventMesh.server.tcp.enabled=true eventMesh.server.tcp.port=10000 @@ -32,36 +30,27 @@ eventMesh.server.tcp.readerIdleSeconds=120 eventMesh.server.tcp.writerIdleSeconds=120 eventMesh.server.tcp.allIdleSeconds=120 eventMesh.server.tcp.clientMaxNum=10000 - # client isolation time if the message send failure eventMesh.server.tcp.pushFailIsolateTimeInMills=30000 - # rebalance internal eventMesh.server.tcp.RebalanceIntervalInMills=30000 - # session expire time about client eventMesh.server.session.expiredInMills=60000 - # flow control, include the global level and session level eventMesh.server.tcp.msgReqnumPerSecond=15000 eventMesh.server.session.upstreamBufferSize=20 eventMesh.server.session.downstreamUnackSize=100 - # thread number about global scheduler eventMesh.server.global.scheduler=5 eventMesh.server.tcp.taskHandleExecutorPoolSize=8 - #retry eventMesh.server.retry.pushRetryTimes=3 eventMesh.server.retry.pushRetryDelayInMills=500 eventMesh.server.retry.pushRetryQueueSize=10000 - #admin eventMesh.server.admin.http.port=10106 - #registry eventMesh.server.registry.registerIntervalInMills=10000 eventMesh.server.registry.fetchRegistryAddrIntervalInMills=20000 - #auto-ack #eventMesh.server.defibus.client.comsumeTimeoutInMin=5 \ No newline at end of file diff --git a/eventmesh-runtime/conf/log4j2.xml b/eventmesh-runtime/conf/log4j2.xml index 8633ab07f3..8495181200 100644 --- a/eventmesh-runtime/conf/log4j2.xml +++ b/eventmesh-runtime/conf/log4j2.xml @@ -64,11 +64,7 @@ - - - - - + diff --git a/eventmesh-runtime/conf/server.env b/eventmesh-runtime/conf/server.env index 4f8c6872ff..f8c01df100 100644 --- a/eventmesh-runtime/conf/server.env +++ b/eventmesh-runtime/conf/server.env @@ -1 +1,18 @@ +# +# 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. APP_START_JVM_OPTION:::-server -Xms128M -Xmx256M -Xmn128m -XX:SurvivorRatio=4 -Duser.language=zh diff --git a/eventmesh-runtime/gradle.properties b/eventmesh-runtime/gradle.properties index b0d1e599ec..60d084498a 100644 --- a/eventmesh-runtime/gradle.properties +++ b/eventmesh-runtime/gradle.properties @@ -14,9 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # - -group=com.webank.eventmesh +group=org.apache.eventmesh version=1.2.0-SNAPSHOT -defibus_version=1.0.1 mavenUserName= mavenPassword= diff --git a/eventmesh-runtime/scripts/before_shutdown.sh b/eventmesh-runtime/scripts/before_shutdown.sh index 20f241071d..9cf8b624a9 100644 --- a/eventmesh-runtime/scripts/before_shutdown.sh +++ b/eventmesh-runtime/scripts/before_shutdown.sh @@ -1,4 +1,21 @@ #!/bin/bash +# +# 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. source session.sh | awk '{print $1}' | awk -F '=' '{print $2}' | awk -F '|' '{print $1,$2}' | grep 2019 > tmp.txt diff --git a/eventmesh-runtime/scripts/client_manage.sh b/eventmesh-runtime/scripts/client_manage.sh index d4c6bd0150..f9367a0f33 100644 --- a/eventmesh-runtime/scripts/client_manage.sh +++ b/eventmesh-runtime/scripts/client_manage.sh @@ -1,4 +1,21 @@ #!/bin/bash +# +# 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. i_eg="sh client_manage.sh -i 10.255.34.160 24591" s_eg="sh client_manage.sh -s FT0 5319" r_eg="sh client_manage.sh -r FT0 9876 10.255.1.143 10000" diff --git a/eventmesh-runtime/scripts/connections.sh b/eventmesh-runtime/scripts/connections.sh index a7a5f3a875..2f691c861f 100644 --- a/eventmesh-runtime/scripts/connections.sh +++ b/eventmesh-runtime/scripts/connections.sh @@ -1,4 +1,21 @@ #!/bin/bash +# +# 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. set -e date; echo -e "active eventmesh connections:\n$(netstat -lnap |grep EST | grep $(jps | grep EventMeshStartup | cut -d" " -f1) | awk -F"[\t ]+" '{print $4}' |sort| uniq -c | sort -rnk1 | grep ":10000")" diff --git a/eventmesh-runtime/scripts/histo.sh b/eventmesh-runtime/scripts/histo.sh index ead3162f95..7d56351082 100644 --- a/eventmesh-runtime/scripts/histo.sh +++ b/eventmesh-runtime/scripts/histo.sh @@ -1,4 +1,21 @@ #!/bin/bash +# +# 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. set -e script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $script_path diff --git a/eventmesh-runtime/scripts/histo_suspects.sh b/eventmesh-runtime/scripts/histo_suspects.sh index 3f77b83ef7..82eaa0b8f7 100644 --- a/eventmesh-runtime/scripts/histo_suspects.sh +++ b/eventmesh-runtime/scripts/histo_suspects.sh @@ -1,4 +1,21 @@ #!/bin/bash +# +# 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. set -e script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $script_path diff --git a/eventmesh-runtime/scripts/jstack.sh b/eventmesh-runtime/scripts/jstack.sh index e36994cc04..ca6e2fdbff 100644 --- a/eventmesh-runtime/scripts/jstack.sh +++ b/eventmesh-runtime/scripts/jstack.sh @@ -1,4 +1,21 @@ #!/bin/bash +# +# 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. set -e script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" echo "[`date`] WARNING this script will PAUSE jvm for seconds." diff --git a/eventmesh-runtime/scripts/monitor_connections.sh b/eventmesh-runtime/scripts/monitor_connections.sh index 6766c1cb9e..fdaf1f63f6 100644 --- a/eventmesh-runtime/scripts/monitor_connections.sh +++ b/eventmesh-runtime/scripts/monitor_connections.sh @@ -1,4 +1,21 @@ #!/bin/bash +# +# 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. set -e script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $script_path diff --git a/eventmesh-runtime/scripts/monitor_histo_suspects.sh b/eventmesh-runtime/scripts/monitor_histo_suspects.sh index f8d7000698..35732cf128 100644 --- a/eventmesh-runtime/scripts/monitor_histo_suspects.sh +++ b/eventmesh-runtime/scripts/monitor_histo_suspects.sh @@ -1,4 +1,21 @@ #!/bin/bash +# +# 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. set -e script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $script_path diff --git a/eventmesh-runtime/scripts/monitor_threads.sh b/eventmesh-runtime/scripts/monitor_threads.sh index 35b5a34174..acf766e353 100644 --- a/eventmesh-runtime/scripts/monitor_threads.sh +++ b/eventmesh-runtime/scripts/monitor_threads.sh @@ -1,4 +1,21 @@ #!/bin/bash +# +# 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. set -e script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $script_path diff --git a/eventmesh-runtime/scripts/session.sh b/eventmesh-runtime/scripts/session.sh index 73a6754dcf..86042c0479 100644 --- a/eventmesh-runtime/scripts/session.sh +++ b/eventmesh-runtime/scripts/session.sh @@ -1,4 +1,21 @@ #!/bin/bash +# +# 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. if [ $# -eq 0 ] then curl -s 'http://127.0.0.1:10106/clientManage/showClient?' diff --git a/eventmesh-runtime/scripts/threads.sh b/eventmesh-runtime/scripts/threads.sh index 4387200e82..fe1eeb5d7f 100644 --- a/eventmesh-runtime/scripts/threads.sh +++ b/eventmesh-runtime/scripts/threads.sh @@ -1,4 +1,21 @@ #!/bin/bash +# +# 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. jstack $(jcmd | grep EventMeshStartup | cut -d" " -f1) | \ grep -vE "(Concurrent GC|DestroyJavaVM|Gang worker|Compiler|Attach Listener|GC Thread|VM Thread|Finalizer)" | \ grep -oE '^".*?"' | \ diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/configuration/CommonConfiguration.java b/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/configuration/CommonConfiguration.java deleted file mode 100644 index 855d187e0f..0000000000 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/configuration/CommonConfiguration.java +++ /dev/null @@ -1,212 +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 com.webank.runtime.configuration; -// -//import com.google.common.base.Preconditions; -//import com.webank.runtime.util.EventMeshUtil; -//import org.apache.commons.lang3.StringUtils; -// -//public class CommonConfiguration { -// public String EventMeshEnv = "P"; -// public String EventMeshRegion = ""; -// public String EventMeshIDC = "FT"; -// public String EventMeshDCN = "1C0"; -// public String eventMeshCluster = "LS"; -// public String eventMeshName = ""; -// public String sysID = "5477"; -// -// -// public String namesrvAddr = ""; -// public String clientUserName = "username"; -// public String clientPass = "user@123"; -// 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 pollNameServerInteval = 10 * 1000; -// public Integer heartbeatBrokerInterval = 30 * 1000; -// public Integer rebalanceInterval = 20 * 1000; -// public Integer eventMeshRegisterIntervalInMills = 10 * 1000; -// public Integer eventMeshFetchRegistryAddrInterval = 10 * 1000; -// public String eventMeshServerIp = null; -// protected ConfigurationWraper configurationWraper; -// -// public CommonConfiguration(ConfigurationWraper configurationWraper) { -// this.configurationWraper = configurationWraper; -// } -// -// public void init() { -// String eventMeshEnvStr = configurationWraper.getProp(ConfKeys.KEYS_eventMesh_ENV); -// Preconditions.checkState(StringUtils.isNotEmpty(eventMeshEnvStr), String.format("%s error", ConfKeys.KEYS_eventMesh_ENV)); -// eventMeshEnv = StringUtils.deleteWhitespace(eventMeshEnvStr); -// -// String eventMeshRegionStr = configurationWraper.getProp(ConfKeys.KEYS_eventMesh_REGION); -// Preconditions.checkState(StringUtils.isNotEmpty(eventMeshRegionStr), String.format("%s error", ConfKeys.KEYS_eventMesh_REGION)); -// eventMeshRegion = StringUtils.deleteWhitespace(eventMeshRegionStr); -// -// String sysIdStr = configurationWraper.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 = configurationWraper.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 = configurationWraper.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 = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_IDC); -// Preconditions.checkState(StringUtils.isNotEmpty(eventMeshIDCStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_IDC)); -// eventMeshIDC = StringUtils.deleteWhitespace(eventMeshIDCStr); -// -// String eventMeshDCNStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DCN); -// Preconditions.checkState(StringUtils.isNotEmpty(eventMeshDCNStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DCN)); -// eventMeshDCN = StringUtils.deleteWhitespace(eventMeshDCNStr); -// -// String clientUserNameStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_USERNAME); -// if (StringUtils.isNotBlank(clientUserNameStr)) { -// clientUserName = StringUtils.trim(clientUserNameStr); -// } -// -// String clientPassStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_PASSWORD); -// if (StringUtils.isNotBlank(clientPassStr)) { -// clientPass = StringUtils.trim(clientPassStr); -// } -// -// String namesrvAddrStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_NAMESRV_ADDR); -// Preconditions.checkState(StringUtils.isNotEmpty(namesrvAddrStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DEFIBUS_NAMESRV_ADDR)); -// namesrvAddr = StringUtils.trim(namesrvAddrStr); -// -// String consumeThreadPoolMinStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_CONSUME_THREADPOOL_MIN); -// if(StringUtils.isNotEmpty(consumeThreadPoolMinStr)){ -// Preconditions.checkState(StringUtils.isNumeric(consumeThreadPoolMinStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DEFIBUS_CONSUME_THREADPOOL_MIN)); -// consumeThreadMin = Integer.valueOf(consumeThreadPoolMinStr); -// } -// -// String consumeThreadPoolMaxStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_CONSUME_THREADPOOL_MAX); -// if(StringUtils.isNotEmpty(consumeThreadPoolMaxStr)){ -// Preconditions.checkState(StringUtils.isNumeric(consumeThreadPoolMaxStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DEFIBUS_CONSUME_THREADPOOL_MAX)); -// consumeThreadMax = Integer.valueOf(consumeThreadPoolMaxStr); -// } -// -// String consumerThreadPoolQueueSizeStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_CONSUME_THREADPOOL_QUEUESIZE); -// if(StringUtils.isNotEmpty(consumerThreadPoolQueueSizeStr)){ -// Preconditions.checkState(StringUtils.isNumeric(consumerThreadPoolQueueSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DEFIBUS_CONSUME_THREADPOOL_QUEUESIZE)); -// consumeQueueSize = Integer.valueOf(consumerThreadPoolQueueSizeStr); -// } -// -// String clientAckWindowStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_ACK_WINDOW); -// if(StringUtils.isNotEmpty(clientAckWindowStr)){ -// Preconditions.checkState(StringUtils.isNumeric(clientAckWindowStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_ACK_WINDOW)); -// ackWindow = Integer.valueOf(clientAckWindowStr); -// } -// -// String clientPubWindowStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_PUB_WINDOW); -// if(StringUtils.isNotEmpty(clientPubWindowStr)){ -// Preconditions.checkState(StringUtils.isNumeric(clientPubWindowStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_PUB_WINDOW)); -// pubWindow = Integer.valueOf(clientPubWindowStr); -// } -// -// String consumeTimeoutStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_CONSUME_TIMEOUT); -// if(StringUtils.isNotBlank(consumeTimeoutStr)) { -// Preconditions.checkState(StringUtils.isNumeric(consumeTimeoutStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_CONSUME_TIMEOUT)); -// consumeTimeout = Long.valueOf(consumeTimeoutStr); -// } -// -// String clientPullBatchSizeStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_PULL_BATCHSIZE); -// if(StringUtils.isNotEmpty(clientPullBatchSizeStr)){ -// Preconditions.checkState(StringUtils.isNumeric(clientPullBatchSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_PULL_BATCHSIZE)); -// pullBatchSize = Integer.valueOf(clientPullBatchSizeStr); -// } -// -// String clientPollNamesrvIntervalStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_POLL_NAMESRV_INTERVAL); -// if(StringUtils.isNotEmpty(clientPollNamesrvIntervalStr)){ -// Preconditions.checkState(StringUtils.isNumeric(clientPollNamesrvIntervalStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_POLL_NAMESRV_INTERVAL)); -// pollNameServerInteval = Integer.valueOf(clientPollNamesrvIntervalStr); -// } -// -// String clientHeartbeatBrokerIntervalStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_HEARTBEAT_BROKER_INTERVEL); -// if(StringUtils.isNotEmpty(clientHeartbeatBrokerIntervalStr)){ -// Preconditions.checkState(StringUtils.isNumeric(clientHeartbeatBrokerIntervalStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_HEARTBEAT_BROKER_INTERVEL)); -// heartbeatBrokerInterval = Integer.valueOf(clientHeartbeatBrokerIntervalStr); -// } -// -// String clientRebalanceIntervalIntervalStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_REBALANCE_INTERVEL); -// if(StringUtils.isNotEmpty(clientRebalanceIntervalIntervalStr)){ -// Preconditions.checkState(StringUtils.isNumeric(clientRebalanceIntervalIntervalStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_DEFIBUS_CLIENT_REBALANCE_INTERVEL)); -// rebalanceInterval = Integer.valueOf(clientRebalanceIntervalIntervalStr); -// } -// -// eventMeshServerIp = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_HOST_IP); -// if(StringUtils.isBlank(eventMeshServerIp)) { -// eventMeshServerIp = EventMeshUtil.getLocalAddr(); -// } -// } -// -// static class ConfKeys { -// public static String KEYS_EVENTMESH_ENV = "eventMesh.server.env"; -// -// public static String KEYS_EVENTMESH_REGION = "eventMesh.server.region"; -// -// public static String KEYS_EVENTMESH_IDC = "eventMesh.server.idc"; -// -// public static String KEYS_EVENTMESH_DCN = "eventMesh.server.dcn"; -// -// public static String KEYS_EVENTMESH_SYSID = "eventMesh.sysid"; -// -// public static String KEYS_EVENTMESH_SERVER_CLUSTER = "eventMesh.server.cluster"; -// -// public static String KEYS_EVENTMESH_SERVER_NAME = "eventMesh.server.name"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_NAMESRV_ADDR = "eventMesh.server.defibus.namesrvAddr"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_USERNAME = "eventMesh.server.defibus.username"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_PASSWORD = "eventMesh.server.defibus.password"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_CONSUME_THREADPOOL_MIN = "eventMesh.server.defibus.client.consumeThreadMin"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_CONSUME_THREADPOOL_MAX = "eventMesh.server.defibus.client.consumeThreadMax"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_CONSUME_THREADPOOL_QUEUESIZE = "eventMesh.server.defibus.client.consumeThreadPoolQueueSize"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_CLIENT_ACK_WINDOW = "eventMesh.server.defibus.client.ackwindow"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_CLIENT_PUB_WINDOW = "eventMesh.server.defibus.client.pubwindow"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_CLIENT_CONSUME_TIMEOUT = "eventMesh.server.defibus.client.comsumeTimeoutInMin"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_CLIENT_PULL_BATCHSIZE = "eventMesh.server.defibus.client.pullBatchSize"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_CLIENT_POLL_NAMESRV_INTERVAL = "eventMesh.server.defibus.client.pollNameServerInterval"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_CLIENT_HEARTBEAT_BROKER_INTERVEL = "eventMesh.server.defibus.client.heartbeatBrokerInterval"; -// -// public static String KEYS_EVENTMESH_DEFIBUS_CLIENT_REBALANCE_INTERVEL = "eventMesh.server.defibus.client.rebalanceInterval"; -// -// 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_FETCH_REGISTRY_ADDR_INTERVAL = "eventMesh.server.registry.fetchRegistryAddrIntervalInMills"; -// } -//} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/configuration/ConfigurationWraper.java b/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/configuration/ConfigurationWraper.java deleted file mode 100644 index d3fc20c9ad..0000000000 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/configuration/ConfigurationWraper.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. -// */ -// -//package com.webank.runtime.configuration; -// -//import com.webank.eventmesh.common.ThreadPoolFactory; -//import org.apache.commons.lang3.StringUtils; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -// -//import java.io.BufferedReader; -//import java.io.File; -//import java.io.FileReader; -//import java.io.IOException; -//import java.util.Properties; -//import java.util.concurrent.ScheduledExecutorService; -//import java.util.concurrent.TimeUnit; -// -//public class ConfigurationWraper { -// -// 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-"); -// -// public ConfigurationWraper(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() { -// try { -// logger.info("loading config: {}", file); -// properties.load(new BufferedReader(new FileReader( -// new File(file)))); -// } catch (IOException e) { -// logger.error("loading properties [{}] error", file, e); -// } -// } -// -// public String getProp(String key) { -// return StringUtils.isEmpty(key) ? null : properties.getProperty(key, null); -// } -// -// -//} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/configuration/EventMeshHTTPConfiguration.java b/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/configuration/EventMeshHTTPConfiguration.java deleted file mode 100644 index 8a230eea48..0000000000 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/configuration/EventMeshHTTPConfiguration.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 com.webank.eventmesh.runtime.configuration; - -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.RateLimiter; -import com.webank.eventmesh.common.config.CommonConfiguration; -import com.webank.eventmesh.common.config.ConfigurationWraper; -import org.apache.commons.lang3.StringUtils; - -public class EventMeshHTTPConfiguration extends CommonConfiguration { - - public int httpServerPort = 10105; - - public RateLimiter eventMeshServerBatchMsgNumLimiter = RateLimiter.create(20000); - - public boolean eventMeshServerBatchMsgBatchEnabled = Boolean.TRUE; - - public int eventMeshServerBatchMsgThreadNum = 10; - - public int eventMeshServerSendMsgThreadNum = 8; - - public int eventMeshServerPushMsgThreadNum = 8; - - public int eventMeshServerReplyMsgThreadNum = 8; - - public int eventMeshServerClientManageThreadNum = 4; - - public int eventMeshServerRegistryThreadNum = 10; - - public int eventMeshServerAdminThreadNum = 2; - - public int eventMeshServerRetryThreadNum = 2; - - public int eventMeshServerPullRegistryIntervel = 30000; - - public int eventMeshServerAsyncAccumulationThreshold = 1000; - - public int eventMeshServerRetryBlockQSize = 10000; - - public int eventMeshServerBatchBlockQSize = 1000; - - public int eventMeshServerSendMsgBlockQSize = 1000; - - public int eventMeshServerPushMsgBlockQSize = 1000; - - public int eventMeshServerClientManageBlockQSize = 1000; - - public int eventMeshServerBusyCheckIntervel = 1000; - - public boolean eventMeshServerConsumerEnabled = false; - - public boolean eventMeshServerUseTls = false; - - public EventMeshHTTPConfiguration(ConfigurationWraper configurationWraper){ - super(configurationWraper); - } - - @Override - public void init(){ - super.init(); - - String httpServerPortStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_HTTP_PORT); - Preconditions.checkState(StringUtils.isNotEmpty(httpServerPortStr) && StringUtils.isNumeric(httpServerPortStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_HTTP_PORT)); - httpServerPort = Integer.valueOf(StringUtils.deleteWhitespace(httpServerPortStr)); - - String eventMeshServerBatchMsgThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_THREAD_NUM); - if (StringUtils.isNotEmpty(eventMeshServerBatchMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerBatchMsgThreadNumStr)) { - eventMeshServerBatchMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBatchMsgThreadNumStr)); - } - - String eventMeshServerBatchMsgNumLimiterStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_RATELIMITER); - if (StringUtils.isNotEmpty(eventMeshServerBatchMsgNumLimiterStr) && StringUtils.isNumeric(eventMeshServerBatchMsgNumLimiterStr)) { - eventMeshServerBatchMsgNumLimiter = RateLimiter.create(Double.valueOf(StringUtils.deleteWhitespace(eventMeshServerBatchMsgNumLimiterStr))); - } - - String eventMeshServerBatchMsgBatchEnableStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_BATCH_ENABLED); - if (StringUtils.isNotBlank(eventMeshServerBatchMsgBatchEnableStr)) { - eventMeshServerBatchMsgBatchEnabled = Boolean.valueOf(eventMeshServerBatchMsgBatchEnableStr); - } - - String eventMeshServerAsyncAccumulationThresholdStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ASYNC_ACCUMULATION_THRESHOLD); - if (StringUtils.isNotEmpty(eventMeshServerAsyncAccumulationThresholdStr) && StringUtils.isNumeric(eventMeshServerAsyncAccumulationThresholdStr)) { - eventMeshServerAsyncAccumulationThreshold = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerAsyncAccumulationThresholdStr)); - } - - String eventMeshServerSendMsgThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SENDMSG_THREAD_NUM); - if (StringUtils.isNotEmpty(eventMeshServerSendMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerSendMsgThreadNumStr)) { - eventMeshServerSendMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerSendMsgThreadNumStr)); - } - - String eventMeshServerReplyMsgThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_REPLYMSG_THREAD_NUM); - if (StringUtils.isNotEmpty(eventMeshServerReplyMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerReplyMsgThreadNumStr)) { - eventMeshServerReplyMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerReplyMsgThreadNumStr)); - } - - String eventMeshServerPushMsgThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_PUSHMSG_THREAD_NUM); - if (StringUtils.isNotEmpty(eventMeshServerPushMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerPushMsgThreadNumStr)) { - eventMeshServerPushMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPushMsgThreadNumStr)); - } - - String eventMeshServerRegistryThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_REGISTRY_THREAD_NUM); - if (StringUtils.isNotEmpty(eventMeshServerRegistryThreadNumStr) && StringUtils.isNumeric(eventMeshServerRegistryThreadNumStr)) { - eventMeshServerRegistryThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRegistryThreadNumStr)); - } - - String eventMeshServerClientManageThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_CLIENTMANAGE_THREAD_NUM); - if (StringUtils.isNotEmpty(eventMeshServerClientManageThreadNumStr) && StringUtils.isNumeric(eventMeshServerClientManageThreadNumStr)) { - eventMeshServerClientManageThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageThreadNumStr)); - } - - String eventMeshServerPullRegistryIntervelStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_PULL_REGISTRY_INTERVEL); - if (StringUtils.isNotEmpty(eventMeshServerPullRegistryIntervelStr) && StringUtils.isNumeric(eventMeshServerPullRegistryIntervelStr)) { - eventMeshServerPullRegistryIntervel = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPullRegistryIntervelStr)); - } - - String eventMeshServerAdminThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ADMIN_THREAD_NUM); - if (StringUtils.isNotEmpty(eventMeshServerAdminThreadNumStr) && StringUtils.isNumeric(eventMeshServerAdminThreadNumStr)) { - eventMeshServerAdminThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerAdminThreadNumStr)); - } - - String eventMeshServerRetryBlockQSizeStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_RETRY_BLOCKQ_SIZE); - if (StringUtils.isNotEmpty(eventMeshServerRetryBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerRetryBlockQSizeStr)) { - eventMeshServerRetryBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRetryBlockQSizeStr)); - } - - String eventMeshServerBatchBlockQSizeStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_BATCHMSG_BLOCKQ_SIZE); - if (StringUtils.isNotEmpty(eventMeshServerBatchBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerBatchBlockQSizeStr)) { - eventMeshServerBatchBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBatchBlockQSizeStr)); - } - - String eventMeshServerSendMsgBlockQSizeStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_SENDMSG_BLOCKQ_SIZE); - if (StringUtils.isNotEmpty(eventMeshServerSendMsgBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerSendMsgBlockQSizeStr)) { - eventMeshServerSendMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerSendMsgBlockQSizeStr)); - } - - String eventMeshServerPushMsgBlockQSizeStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_PUSHMSG_BLOCKQ_SIZE); - if (StringUtils.isNotEmpty(eventMeshServerPushMsgBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerPushMsgBlockQSizeStr)) { - eventMeshServerPushMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPushMsgBlockQSizeStr)); - } - - String eventMeshServerClientManageBlockQSizeStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_CLIENTM_BLOCKQ_SIZE); - if (StringUtils.isNotEmpty(eventMeshServerClientManageBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerClientManageBlockQSizeStr)) { - eventMeshServerClientManageBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageBlockQSizeStr)); - } - - String eventMeshServerBusyCheckIntervelStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_BUSY_CHECK_INTERVEL); - if (StringUtils.isNotEmpty(eventMeshServerBusyCheckIntervelStr) && StringUtils.isNumeric(eventMeshServerBusyCheckIntervelStr)) { - eventMeshServerBusyCheckIntervel = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBusyCheckIntervelStr)); - } - - String eventMeshServerConsumerEnabledStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_CONSUMER_ENABLED); - if (StringUtils.isNotEmpty(eventMeshServerConsumerEnabledStr)) { - eventMeshServerConsumerEnabled = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerConsumerEnabledStr)); - } - - String eventMeshServerRetryThreadNumStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_RETRY_THREAD_NUM); - if (StringUtils.isNotEmpty(eventMeshServerRetryThreadNumStr) && StringUtils.isNumeric(eventMeshServerRetryThreadNumStr)) { - eventMeshServerRetryThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRetryThreadNumStr)); - } - - String eventMeshServerUseTlsStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_HTTPS_ENABLED); - if (StringUtils.isNotEmpty(eventMeshServerUseTlsStr)) { - eventMeshServerUseTls = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerUseTlsStr)); - } - } - - static class ConfKeys{ - - public static String KEYS_EVENTMESH_SERVER_HTTP_PORT = "eventMesh.server.http.port"; - - public static String KEYS_EVENTMESH_BATCHMSG_THREAD_NUM = "eventMesh.server.batchmsg.threads.num"; - - public static String KEYS_EVENTMESH_BATCHMSG_RATELIMITER = "eventMesh.server.batchmsg.speed.ratelimiter"; - - 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_INTERVEL = "eventMesh.server.busy.check.intervel"; - - 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_INTERVEL = "eventMesh.server.pull.registry.intervel"; - - 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_HTTPS_ENABLED = "eventMesh.server.useTls.enabled"; - } -} diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/plugin/MQWrapper.java b/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/plugin/MQWrapper.java deleted file mode 100644 index d5daf5fde8..0000000000 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/plugin/MQWrapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.webank.eventmesh.runtime.core.plugin; - -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import org.apache.commons.lang3.StringUtils; - -import java.util.concurrent.atomic.AtomicBoolean; - -public abstract class MQWrapper { - - public static final String EVENT_STORE_ROCKETMQ = "rocketmq"; - - public static final String EVENT_STORE_DEFIBUS = "defibus"; - - public static String CURRENT_EVENT_STORE = EVENT_STORE_DEFIBUS; - - public static final String EVENT_STORE_CONF = System.getProperty(EventMeshConstants.EVENT_STORE_PROPERTIES, System.getenv(EventMeshConstants.EVENT_STORE_ENV)); - - static { - if (StringUtils.isNotBlank(EVENT_STORE_CONF)) { - CURRENT_EVENT_STORE = EVENT_STORE_CONF; - } - } - - public AtomicBoolean started = new AtomicBoolean(Boolean.FALSE); - - public AtomicBoolean inited = new AtomicBoolean(Boolean.FALSE); - -} diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/MessageClientIDSetter.java b/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/MessageClientIDSetter.java deleted file mode 100644 index c71bdb54f9..0000000000 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/MessageClientIDSetter.java +++ /dev/null @@ -1,205 +0,0 @@ -package com.webank.eventmesh.runtime.util; - -import io.openmessaging.api.Message; - -import java.lang.management.ManagementFactory; -import java.lang.management.RuntimeMXBean; -import java.net.Inet4Address; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.nio.ByteBuffer; -import java.util.Calendar; -import java.util.Enumeration; -import java.util.concurrent.atomic.AtomicInteger; - -public class MessageClientIDSetter { - - public static final String PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX = "UNIQ_KEY"; - private static final String TOPIC_KEY_SPLITTER = "#"; - private static final int LEN; - private static final String FIX_STRING; - private static final AtomicInteger COUNTER; - private static long startTime; - private static long nextStartTime; - - final static char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); - - static { - LEN = 4 + 2 + 4 + 4 + 2; - ByteBuffer tempBuffer = ByteBuffer.allocate(10); - tempBuffer.position(2); - tempBuffer.putInt(getPid()); - tempBuffer.position(0); - try { - tempBuffer.put(getIP()); - } catch (Exception e) { - tempBuffer.put(createFakeIP()); - } - tempBuffer.position(6); - tempBuffer.putInt(MessageClientIDSetter.class.getClassLoader().hashCode()); - FIX_STRING = bytes2string(tempBuffer.array()); - setStartTime(System.currentTimeMillis()); - COUNTER = new AtomicInteger(0); - } - - public static void setUniqID(final Message msg) { - if (msg.getUserProperties(PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX) == null) { - msg.getUserProperties().put(PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX, createUniqID()); - } - } - - public static String createUniqID() { - StringBuilder sb = new StringBuilder(LEN * 2); - sb.append(FIX_STRING); - sb.append(bytes2string(createUniqIDBuffer())); - return sb.toString(); - } - - public static String bytes2string(byte[] src) { - char[] hexChars = new char[src.length * 2]; - for (int j = 0; j < src.length; j++) { - int v = src[j] & 0xFF; - hexChars[j * 2] = HEX_ARRAY[v >>> 4]; - hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; - } - return new String(hexChars); - } - - private synchronized static void setStartTime(long millis) { - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(millis); - cal.set(Calendar.DAY_OF_MONTH, 1); - cal.set(Calendar.HOUR_OF_DAY, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - startTime = cal.getTimeInMillis(); - cal.add(Calendar.MONTH, 1); - nextStartTime = cal.getTimeInMillis(); - } - - private static byte[] createUniqIDBuffer() { - ByteBuffer buffer = ByteBuffer.allocate(4 + 2); - long current = System.currentTimeMillis(); - if (current >= nextStartTime) { - setStartTime(current); - } - buffer.position(0); - buffer.putInt((int) (System.currentTimeMillis() - startTime)); - buffer.putShort((short) COUNTER.getAndIncrement()); - return buffer.array(); - } - - public static byte[] createFakeIP() { - ByteBuffer bb = ByteBuffer.allocate(8); - bb.putLong(System.currentTimeMillis()); - bb.position(4); - byte[] fakeIP = new byte[4]; - bb.get(fakeIP); - return fakeIP; - } - - public static int getPid() { - RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); - String name = runtime.getName(); // format: "pid@hostname" - try { - return Integer.parseInt(name.substring(0, name.indexOf('@'))); - } catch (Exception e) { - return -1; - } - } - - public static byte[] getIP() { - try { - Enumeration allNetInterfaces = NetworkInterface.getNetworkInterfaces(); - InetAddress ip = null; - byte[] internalIP = null; - while (allNetInterfaces.hasMoreElements()) { - NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement(); - Enumeration addresses = netInterface.getInetAddresses(); - while (addresses.hasMoreElements()) { - ip = (InetAddress) addresses.nextElement(); - if (ip != null && ip instanceof Inet4Address) { - byte[] ipByte = ip.getAddress(); - if (ipByte.length == 4) { - if (ipCheck(ipByte)) { - if (!isInternalIP(ipByte)) { - return ipByte; - } else if (internalIP == null) { - internalIP = ipByte; - } - } - } - } - } - } - if (internalIP != null) { - return internalIP; - } else { - throw new RuntimeException("Can not get local ip"); - } - } catch (Exception e) { - throw new RuntimeException("Can not get local ip", e); - } - } - - public static boolean isInternalIP(byte[] ip) { - if (ip.length != 4) { - throw new RuntimeException("illegal ipv4 bytes"); - } - - //10.0.0.0~10.255.255.255 - //172.16.0.0~172.31.255.255 - //192.168.0.0~192.168.255.255 - if (ip[0] == (byte) 10) { - - return true; - } else if (ip[0] == (byte) 172) { - if (ip[1] >= (byte) 16 && ip[1] <= (byte) 31) { - return true; - } - } else if (ip[0] == (byte) 192) { - if (ip[1] == (byte) 168) { - return true; - } - } - return false; - } - - private static boolean ipCheck(byte[] ip) { - if (ip.length != 4) { - throw new RuntimeException("illegal ipv4 bytes"); - } - -// if (ip[0] == (byte)30 && ip[1] == (byte)10 && ip[2] == (byte)163 && ip[3] == (byte)120) { -// } - - if (ip[0] >= (byte) 1 && ip[0] <= (byte) 126) { - if (ip[1] == (byte) 1 && ip[2] == (byte) 1 && ip[3] == (byte) 1) { - return false; - } - if (ip[1] == (byte) 0 && ip[2] == (byte) 0 && ip[3] == (byte) 0) { - return false; - } - return true; - } else if (ip[0] >= (byte) 128 && ip[0] <= (byte) 191) { - if (ip[2] == (byte) 1 && ip[3] == (byte) 1) { - return false; - } - if (ip[2] == (byte) 0 && ip[3] == (byte) 0) { - return false; - } - return true; - } else if (ip[0] >= (byte) 192 && ip[0] <= (byte) 223) { - if (ip[3] == (byte) 1) { - return false; - } - if (ip[3] == (byte) 0) { - return false; - } - return true; - } - return false; - } - -} diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/admin/controller/ClientManageController.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/ClientManageController.java similarity index 84% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/admin/controller/ClientManageController.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/ClientManageController.java index 1d0e508684..f93e1af006 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/admin/controller/ClientManageController.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/ClientManageController.java @@ -15,21 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.admin.controller; - -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcp2Client; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.group.ClientGroupWrapper; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.group.ClientSessionGroupMapping; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpServer; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.runtime.admin.controller; import java.io.BufferedReader; import java.io.IOException; @@ -49,17 +35,32 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; + +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcp2Client; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.group.ClientGroupWrapper; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.group.ClientSessionGroupMapping; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class ClientManageController { private static final Logger logger = LoggerFactory.getLogger(ClientManageController.class); private EventMeshTCPServer eventMeshTCPServer; - public ClientManageController(EventMeshTCPServer eventMeshTCPServer){ + public ClientManageController(EventMeshTCPServer eventMeshTCPServer) { this.eventMeshTCPServer = eventMeshTCPServer; } - public void start() throws IOException { + public void start() throws IOException { int port = eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshServerAdminPort; HttpServer server = HttpServer.create(new InetSocketAddress(port), 0); server.createContext("/clientManage/showClient", new ShowClientHandler()); @@ -82,7 +83,7 @@ private Map parsePostParameters(HttpExchange exchange) Map parameters = new HashMap<>(); if ("post".equalsIgnoreCase(exchange.getRequestMethod())) { InputStreamReader isr = - new InputStreamReader(exchange.getRequestBody(),"utf-8"); + new InputStreamReader(exchange.getRequestBody(), "utf-8"); BufferedReader br = new BufferedReader(isr); String query = br.readLine(); parseQuery(query, parameters); @@ -103,21 +104,21 @@ private void parseQuery(String query, Map parameters) String key = null; String value = null; if (param.length > 0) { - key = URLDecoder.decode(param[0],"UTF-8"); + key = URLDecoder.decode(param[0], "UTF-8"); } if (param.length > 1) { - value = URLDecoder.decode(param[1],"UTF-8"); + value = URLDecoder.decode(param[1], "UTF-8"); } if (parameters.containsKey(key)) { Object obj = parameters.get(key); - if(obj instanceof List) { - List values = (List)obj; + if (obj instanceof List) { + List values = (List) obj; values.add(value); - } else if(obj instanceof String) { + } else if (obj instanceof String) { List values = new ArrayList(); - values.add((String)obj); + values.add((String) obj); values.add(value); parameters.put(key, values); } @@ -133,12 +134,12 @@ private void parseQuery(String query, Map parameters) * * @return */ - class ShowClientHandler implements HttpHandler{ + class ShowClientHandler implements HttpHandler { @Override public void handle(HttpExchange httpExchange) throws IOException { String result = ""; OutputStream out = httpExchange.getResponseBody(); - try{ + try { String newLine = System.getProperty("line.separator"); logger.info("showAllClient================="); ClientSessionGroupMapping clientSessionGroupMapping = eventMeshTCPServer.getClientSessionGroupMapping(); @@ -157,13 +158,13 @@ public void handle(HttpExchange httpExchange) throws IOException { } httpExchange.sendResponseHeaders(200, 0); out.write(result.getBytes()); - }catch (Exception e){ + } catch (Exception e) { logger.error("ShowClientHandler fail...", e); - }finally { - if(out != null){ + } finally { + if (out != null) { try { out.close(); - }catch (IOException e){ + } catch (IOException e) { logger.warn("out close failed...", e); } } @@ -184,19 +185,19 @@ public int compare(Map.Entry x, Map.Entry queryStringInfo = formData2Dic(queryString); + try { + String queryString = httpExchange.getRequestURI().getQuery(); + Map queryStringInfo = formData2Dic(queryString); String dcn = queryStringInfo.get(EventMeshConstants.MANAGE_DCN); String subSystem = queryStringInfo.get(EventMeshConstants.MANAGE_SUBSYSTEM); String newLine = System.getProperty("line.separator"); - logger.info("showClientBySubsysAndDcn,subsys:{},dcn:{}=================",subSystem,dcn); + logger.info("showClientBySubsysAndDcn,subsys:{},dcn:{}=================", subSystem, dcn); ClientSessionGroupMapping clientSessionGroupMapping = eventMeshTCPServer.getClientSessionGroupMapping(); ConcurrentHashMap sessionMap = clientSessionGroupMapping.getSessionMap(); if (!sessionMap.isEmpty()) { @@ -210,13 +211,13 @@ public void handle(HttpExchange httpExchange) throws IOException { } httpExchange.sendResponseHeaders(200, 0); out.write(result.getBytes()); - }catch (Exception e){ + } catch (Exception e) { logger.error("ShowClientBySystemAndDcnHandler fail...", e); - }finally { - if(out != null){ + } finally { + if (out != null) { try { out.close(); - }catch (IOException e){ + } catch (IOException e) { logger.warn("out close failed...", e); } } @@ -228,28 +229,27 @@ public void handle(HttpExchange httpExchange) throws IOException { /** * query client subscription by topic - * */ - class ShowListenClientByTopicHandler implements HttpHandler{ + class ShowListenClientByTopicHandler implements HttpHandler { @Override public void handle(HttpExchange httpExchange) throws IOException { String result = ""; OutputStream out = httpExchange.getResponseBody(); - try{ - String queryString = httpExchange.getRequestURI().getQuery(); - Map queryStringInfo = formData2Dic(queryString); + try { + String queryString = httpExchange.getRequestURI().getQuery(); + Map queryStringInfo = formData2Dic(queryString); String topic = queryStringInfo.get(EventMeshConstants.MANAGE_TOPIC); String newLine = System.getProperty("line.separator"); - logger.info("showListeningClientByTopic,topic:{}=================",topic); + logger.info("showListeningClientByTopic,topic:{}=================", topic); ClientSessionGroupMapping clientSessionGroupMapping = eventMeshTCPServer.getClientSessionGroupMapping(); ConcurrentHashMap clientGroupMap = clientSessionGroupMapping.getClientGroupMap(); if (!clientGroupMap.isEmpty()) { for (ClientGroupWrapper cgw : clientGroupMap.values()) { Set listenSessionSet = cgw.getTopic2sessionInGroupMapping().get(topic); if (listenSessionSet != null && listenSessionSet.size() > 0) { - result += String.format("group:%s",cgw.getGroupName()) + newLine; - for(Session session : listenSessionSet) { + result += String.format("group:%s", cgw.getGroupName()) + newLine; + for (Session session : listenSessionSet) { UserAgent userAgent = session.getClient(); result += String.format("pid=%s | ip=%s | port=%s | path=%s | version=%s", userAgent.getPid(), userAgent .getHost(), userAgent.getPort(), userAgent.getPath(), userAgent.getVersion()) + newLine; @@ -259,13 +259,13 @@ public void handle(HttpExchange httpExchange) throws IOException { } httpExchange.sendResponseHeaders(200, 0); out.write(result.getBytes()); - }catch (Exception e){ + } catch (Exception e) { logger.error("ShowListenClientByTopicHandler fail...", e); - }finally { - if(out != null){ + } finally { + if (out != null) { try { out.close(); - }catch (IOException e){ + } catch (IOException e) { logger.warn("out close failed...", e); } } @@ -280,12 +280,12 @@ public void handle(HttpExchange httpExchange) throws IOException { * * @return */ - class RejectAllClientHandler implements HttpHandler{ + class RejectAllClientHandler implements HttpHandler { @Override public void handle(HttpExchange httpExchange) throws IOException { String result = ""; OutputStream out = httpExchange.getResponseBody(); - try{ + try { ClientSessionGroupMapping clientSessionGroupMapping = eventMeshTCPServer.getClientSessionGroupMapping(); ConcurrentHashMap sessionMap = clientSessionGroupMapping.getSessionMap(); final List successRemoteAddrs = new ArrayList(); @@ -293,7 +293,7 @@ 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(entry.getValue(), clientSessionGroupMapping); + InetSocketAddress addr = EventMeshTcp2Client.serverGoodby2Client(eventMeshTCPServer, entry.getValue(), clientSessionGroupMapping); if (addr != null) { successRemoteAddrs.add(addr); } @@ -311,13 +311,13 @@ public void handle(HttpExchange httpExchange) throws IOException { (), printClients(successRemoteAddrs)); httpExchange.sendResponseHeaders(200, 0); out.write(result.getBytes()); - }catch (Exception e){ + } catch (Exception e) { logger.error("rejectAllClient fail...", e); - }finally { - if(out != null){ + } finally { + if (out != null) { try { out.close(); - }catch (IOException e){ + } catch (IOException e) { logger.warn("out close failed...", e); } } @@ -331,14 +331,14 @@ public void handle(HttpExchange httpExchange) throws IOException { * * @return */ - class RejectClientByIpPortHandler implements HttpHandler{ + class RejectClientByIpPortHandler implements HttpHandler { @Override public void handle(HttpExchange httpExchange) throws IOException { String result = ""; OutputStream out = httpExchange.getResponseBody(); - try{ - String queryString = httpExchange.getRequestURI().getQuery(); - Map queryStringInfo = formData2Dic(queryString); + try { + String queryString = httpExchange.getRequestURI().getQuery(); + Map queryStringInfo = formData2Dic(queryString); String ip = queryStringInfo.get(EventMeshConstants.MANAGE_IP); String port = queryStringInfo.get(EventMeshConstants.MANAGE_PORT); @@ -348,7 +348,7 @@ public void handle(HttpExchange httpExchange) throws IOException { out.write(result.getBytes()); return; } - logger.info("rejectClientByIpPort in admin,ip:{},port:{}====================",ip,port); + logger.info("rejectClientByIpPort in admin,ip:{},port:{}====================", ip, port); ClientSessionGroupMapping clientSessionGroupMapping = eventMeshTCPServer.getClientSessionGroupMapping(); ConcurrentHashMap sessionMap = clientSessionGroupMapping.getSessionMap(); final List successRemoteAddrs = new ArrayList(); @@ -356,7 +356,7 @@ public void handle(HttpExchange httpExchange) throws IOException { if (!sessionMap.isEmpty()) { for (Map.Entry entry : sessionMap.entrySet()) { if (entry.getKey().getHostString().equals(ip) && String.valueOf(entry.getKey().getPort()).equals(port)) { - InetSocketAddress addr = EventMeshTcp2Client.serverGoodby2Client(entry.getValue(), clientSessionGroupMapping); + InetSocketAddress addr = EventMeshTcp2Client.serverGoodby2Client(eventMeshTCPServer, entry.getValue(), clientSessionGroupMapping); if (addr != null) { successRemoteAddrs.add(addr); } @@ -376,13 +376,13 @@ public void handle(HttpExchange httpExchange) throws IOException { (successRemoteAddrs)); httpExchange.sendResponseHeaders(200, 0); out.write(result.getBytes()); - }catch (Exception e){ + } catch (Exception e) { logger.error("rejectClientByIpPort fail...", e); - }finally { - if(out != null){ + } finally { + if (out != null) { try { out.close(); - }catch (IOException e){ + } catch (IOException e) { logger.warn("out close failed...", e); } } @@ -397,14 +397,14 @@ public void handle(HttpExchange httpExchange) throws IOException { * * @return */ - class RejectClientBySubSystemHandler implements HttpHandler{ + class RejectClientBySubSystemHandler implements HttpHandler { @Override public void handle(HttpExchange httpExchange) throws IOException { String result = ""; OutputStream out = httpExchange.getResponseBody(); - try{ - String queryString = httpExchange.getRequestURI().getQuery(); - Map queryStringInfo = formData2Dic(queryString); + try { + String queryString = httpExchange.getRequestURI().getQuery(); + Map queryStringInfo = formData2Dic(queryString); String dcn = queryStringInfo.get(EventMeshConstants.MANAGE_DCN); String subSystem = queryStringInfo.get(EventMeshConstants.MANAGE_SUBSYSTEM); @@ -415,7 +415,7 @@ public void handle(HttpExchange httpExchange) throws IOException { return; } - logger.info("rejectClientBySubSystem in admin,subsys:{},dcn:{}====================",subSystem,dcn); + logger.info("rejectClientBySubSystem in admin,subsys:{},dcn:{}====================", subSystem, dcn); ClientSessionGroupMapping clientSessionGroupMapping = eventMeshTCPServer.getClientSessionGroupMapping(); ConcurrentHashMap sessionMap = clientSessionGroupMapping.getSessionMap(); final List successRemoteAddrs = new ArrayList(); @@ -423,7 +423,7 @@ public void handle(HttpExchange httpExchange) throws IOException { if (!sessionMap.isEmpty()) { for (Session session : sessionMap.values()) { if (session.getClient().getDcn().equals(dcn) && session.getClient().getSubsystem().equals(subSystem)) { - InetSocketAddress addr = EventMeshTcp2Client.serverGoodby2Client(session, clientSessionGroupMapping); + InetSocketAddress addr = EventMeshTcp2Client.serverGoodby2Client(eventMeshTCPServer, session, clientSessionGroupMapping); if (addr != null) { successRemoteAddrs.add(addr); } @@ -443,13 +443,13 @@ public void handle(HttpExchange httpExchange) throws IOException { "port=%s}", sessionMap.size(), printClients(successRemoteAddrs), dcn, subSystem); httpExchange.sendResponseHeaders(200, 0); out.write(result.getBytes()); - }catch (Exception e){ + } catch (Exception e) { logger.error("rejectClientBySubSystem fail...", e); - }finally { - if(out != null){ + } finally { + if (out != null) { try { out.close(); - }catch (IOException e){ + } catch (IOException e) { logger.warn("out close failed...", e); } } @@ -463,14 +463,14 @@ public void handle(HttpExchange httpExchange) throws IOException { * * @return */ - class RedirectClientBySubSystemHandler implements HttpHandler{ + class RedirectClientBySubSystemHandler implements HttpHandler { @Override public void handle(HttpExchange httpExchange) throws IOException { String result = ""; OutputStream out = httpExchange.getResponseBody(); - try{ - String queryString = httpExchange.getRequestURI().getQuery(); - Map queryStringInfo = formData2Dic(queryString); + try { + String queryString = httpExchange.getRequestURI().getQuery(); + Map queryStringInfo = formData2Dic(queryString); String dcn = queryStringInfo.get(EventMeshConstants.MANAGE_DCN); String subSystem = queryStringInfo.get(EventMeshConstants.MANAGE_SUBSYSTEM); String destEventMeshIp = queryStringInfo.get(EventMeshConstants.MANAGE_DEST_IP); @@ -484,7 +484,7 @@ public void handle(HttpExchange httpExchange) throws IOException { out.write(result.getBytes()); return; } - logger.info("redirectClientBySubSystem in admin,subsys:{},dcn:{},destIp:{},destPort:{}====================",subSystem,dcn,destEventMeshIp,destEventMeshPort); + logger.info("redirectClientBySubSystem in admin,subsys:{},dcn:{},destIp:{},destPort:{}====================", subSystem, dcn, destEventMeshIp, destEventMeshPort); ClientSessionGroupMapping clientSessionGroupMapping = eventMeshTCPServer.getClientSessionGroupMapping(); ConcurrentHashMap sessionMap = clientSessionGroupMapping.getSessionMap(); String redirectResult = ""; @@ -493,7 +493,7 @@ public void handle(HttpExchange httpExchange) throws IOException { for (Session session : sessionMap.values()) { if (session.getClient().getDcn().equals(dcn) && session.getClient().getSubsystem().equals(subSystem)) { redirectResult += "|"; - redirectResult += EventMeshTcp2Client.redirectClient2NewEventMesh(destEventMeshIp, Integer.parseInt(destEventMeshPort), + redirectResult += EventMeshTcp2Client.redirectClient2NewEventMesh(eventMeshTCPServer, destEventMeshIp, Integer.parseInt(destEventMeshPort), session, clientSessionGroupMapping); } } @@ -514,13 +514,13 @@ public void handle(HttpExchange httpExchange) throws IOException { sessionMap.size(), dcn, subSystem, destEventMeshIp, destEventMeshPort, redirectResult); httpExchange.sendResponseHeaders(200, 0); out.write(result.getBytes()); - }catch (Exception e){ + } catch (Exception e) { logger.error("redirectClientBySubSystem fail...", e); - }finally { - if(out != null){ + } finally { + if (out != null) { try { out.close(); - }catch (IOException e){ + } catch (IOException e) { logger.warn("out close failed...", e); } } @@ -528,20 +528,20 @@ public void handle(HttpExchange httpExchange) throws IOException { } } - + /** * redirect subsystem for path * * @return */ - class RedirectClientByPathHandler implements HttpHandler{ + class RedirectClientByPathHandler implements HttpHandler { @Override public void handle(HttpExchange httpExchange) throws IOException { String result = ""; OutputStream out = httpExchange.getResponseBody(); - try{ - String queryString = httpExchange.getRequestURI().getQuery(); - Map queryStringInfo = formData2Dic(queryString); + try { + String queryString = httpExchange.getRequestURI().getQuery(); + Map queryStringInfo = formData2Dic(queryString); String path = queryStringInfo.get(EventMeshConstants.MANAGE_PATH); String destEventMeshIp = queryStringInfo.get(EventMeshConstants.MANAGE_DEST_IP); String destEventMeshPort = queryStringInfo.get(EventMeshConstants.MANAGE_DEST_PORT); @@ -553,7 +553,7 @@ public void handle(HttpExchange httpExchange) throws IOException { out.write(result.getBytes()); return; } - logger.info("redirectClientByPath in admin,path:{},destIp:{},destPort:{}====================",path,destEventMeshIp,destEventMeshPort); + logger.info("redirectClientByPath in admin,path:{},destIp:{},destPort:{}====================", path, destEventMeshIp, destEventMeshPort); ClientSessionGroupMapping clientSessionGroupMapping = eventMeshTCPServer.getClientSessionGroupMapping(); ConcurrentHashMap sessionMap = clientSessionGroupMapping.getSessionMap(); String redirectResult = ""; @@ -562,7 +562,7 @@ public void handle(HttpExchange httpExchange) throws IOException { for (Session session : sessionMap.values()) { if (session.getClient().getPath().contains(path)) { redirectResult += "|"; - redirectResult += EventMeshTcp2Client.redirectClient2NewEventMesh(destEventMeshIp, Integer.parseInt(destEventMeshPort), + redirectResult += EventMeshTcp2Client.redirectClient2NewEventMesh(eventMeshTCPServer, destEventMeshIp, Integer.parseInt(destEventMeshPort), session, clientSessionGroupMapping); } } @@ -583,13 +583,13 @@ public void handle(HttpExchange httpExchange) throws IOException { sessionMap.size(), path, destEventMeshIp, destEventMeshPort, redirectResult); httpExchange.sendResponseHeaders(200, 0); out.write(result.getBytes()); - }catch (Exception e){ + } catch (Exception e) { logger.error("redirectClientByPath fail...", e); - }finally { - if(out != null){ + } finally { + if (out != null) { try { out.close(); - }catch (IOException e){ + } catch (IOException e) { logger.warn("out close failed...", e); } } @@ -603,14 +603,14 @@ public void handle(HttpExchange httpExchange) throws IOException { * * @return */ - class RedirectClientByIpPortHandler implements HttpHandler{ + class RedirectClientByIpPortHandler implements HttpHandler { @Override public void handle(HttpExchange httpExchange) throws IOException { String result = ""; OutputStream out = httpExchange.getResponseBody(); - try{ - String queryString = httpExchange.getRequestURI().getQuery(); - Map queryStringInfo = formData2Dic(queryString); + try { + String queryString = httpExchange.getRequestURI().getQuery(); + Map queryStringInfo = formData2Dic(queryString); String ip = queryStringInfo.get(EventMeshConstants.MANAGE_IP); String port = queryStringInfo.get(EventMeshConstants.MANAGE_PORT); String destEventMeshIp = queryStringInfo.get(EventMeshConstants.MANAGE_DEST_IP); @@ -624,7 +624,7 @@ public void handle(HttpExchange httpExchange) throws IOException { out.write(result.getBytes()); return; } - logger.info("redirectClientByIpPort in admin,ip:{},port:{},destIp:{},destPort:{}====================",ip,port,destEventMeshIp,destEventMeshPort); + logger.info("redirectClientByIpPort in admin,ip:{},port:{},destIp:{},destPort:{}====================", ip, port, destEventMeshIp, destEventMeshPort); ClientSessionGroupMapping clientSessionGroupMapping = eventMeshTCPServer.getClientSessionGroupMapping(); ConcurrentHashMap sessionMap = clientSessionGroupMapping.getSessionMap(); String redirectResult = ""; @@ -633,7 +633,7 @@ public void handle(HttpExchange httpExchange) throws IOException { for (Session session : sessionMap.values()) { if (session.getClient().getHost().equals(ip) && String.valueOf(session.getClient().getPort()).equals(port)) { redirectResult += "|"; - redirectResult += EventMeshTcp2Client.redirectClient2NewEventMesh(destEventMeshIp, Integer.parseInt(destEventMeshPort), + redirectResult += EventMeshTcp2Client.redirectClient2NewEventMesh(eventMeshTCPServer, destEventMeshIp, Integer.parseInt(destEventMeshPort), session, clientSessionGroupMapping); } } @@ -654,13 +654,13 @@ public void handle(HttpExchange httpExchange) throws IOException { sessionMap.size(), ip, port, destEventMeshIp, destEventMeshPort, redirectResult); httpExchange.sendResponseHeaders(200, 0); out.write(result.getBytes()); - }catch (Exception e){ + } catch (Exception e) { logger.error("redirectClientByIpPort fail...", e); - }finally { - if(out != null){ + } finally { + if (out != null) { try { out.close(); - }catch (IOException e){ + } catch (IOException e) { logger.warn("out close failed...", e); } } @@ -673,27 +673,27 @@ private String printClients(List clients) { if (clients.isEmpty()) { return "no session had been closed"; } - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (InetSocketAddress addr : clients) { sb.append(addr).append("|"); } return sb.toString(); } - private Map formData2Dic(String formData) { - Map result = new HashMap<>(); - if(formData== null || formData.trim().length() == 0) { + private Map formData2Dic(String formData) { + Map result = new HashMap<>(); + if (formData == null || formData.trim().length() == 0) { return result; } final String[] items = formData.split("&"); - Arrays.stream(items).forEach(item ->{ + Arrays.stream(items).forEach(item -> { final String[] keyAndVal = item.split("="); - if( keyAndVal.length == 2) { - try{ - final String key = URLDecoder.decode( keyAndVal[0],"utf8"); - final String val = URLDecoder.decode( keyAndVal[1],"utf8"); - result.put(key,val); - }catch (UnsupportedEncodingException e) { + if (keyAndVal.length == 2) { + try { + final String key = URLDecoder.decode(keyAndVal[0], "utf8"); + final String val = URLDecoder.decode(keyAndVal[1], "utf8"); + result.put(key, val); + } catch (UnsupportedEncodingException e) { logger.warn("formData2Dic:param decode failed...", e); } } @@ -701,12 +701,12 @@ private Map formData2Dic(String formData) { return result; } - class EventMeshMsgDownStreamHandler implements HttpHandler{ + class EventMeshMsgDownStreamHandler implements HttpHandler { @Override public void handle(HttpExchange httpExchange) throws IOException { String result = "false"; OutputStream out = httpExchange.getResponseBody(); - try{ + try { // Map queryStringInfo = parsePostParameters(httpExchange); // String msgStr = (String)queryStringInfo.get("msg"); // String groupName = (String)queryStringInfo.get("group"); @@ -758,13 +758,13 @@ public void handle(HttpExchange httpExchange) throws IOException { // httpExchange.sendResponseHeaders(200, 0); // out.write(result.getBytes()); - }catch (Exception e){ + } catch (Exception e) { logger.error("EventMeshMsgDownStreamHandler handle fail...", e); - }finally { - if(out != null){ + } finally { + if (out != null) { try { out.close(); - }catch (IOException e){ + } catch (IOException e) { logger.warn("out close failed...", e); } } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/AbrstractHTTPServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbrstractHTTPServer.java similarity index 85% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/AbrstractHTTPServer.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbrstractHTTPServer.java index 5210bd2f7a..4e902a6d9d 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/AbrstractHTTPServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbrstractHTTPServer.java @@ -15,52 +15,76 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.boot; +package org.apache.eventmesh.runtime.boot; + +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 com.google.common.base.Preconditions; -import com.webank.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.util.RemotingHelper; -import com.webank.eventmesh.runtime.common.Pair; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.metrics.http.HTTPMetricsServer; -import com.webank.eventmesh.common.ThreadPoolFactory; -import com.webank.eventmesh.common.command.HttpCommand; -import com.webank.eventmesh.common.protocol.http.body.Body; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.common.EventMeshRetCode; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.common.protocol.http.header.Header; + import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.*; +import io.netty.channel.ChannelDuplexHandler; +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.ChannelPipeline; +import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; -import io.netty.handler.codec.http.*; -import io.netty.handler.codec.http.multipart.*; +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.DiskAttribute; +import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder; +import io.netty.handler.codec.http.multipart.InterfaceHttpData; 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 javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; -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; - public abstract class AbrstractHTTPServer extends AbstractRemotingServer { - public Logger logger = LoggerFactory.getLogger(this.getClass()); + public Logger httpServerLogger = LoggerFactory.getLogger(this.getClass()); public Logger httpLogger = LoggerFactory.getLogger("http"); @@ -134,15 +158,15 @@ public void start() throws Exception { .channel(NioServerSocketChannel.class) .childHandler(new HttpsServerInitializer(SSLContextFactory.getSslContext())).childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE); try { - logger.info("HTTPServer[port={}] started......", this.port); + httpServerLogger.info("HTTPServer[port={}] started......", this.port); ChannelFuture future = b.bind(this.port).sync(); future.channel().closeFuture().sync(); } catch (Exception e) { - logger.error("HTTPServer start Err!", e); + httpServerLogger.error("HTTPServer start Err!", e); try { shutdown(); } catch (Exception e1) { - logger.error("HTTPServer shutdown Err!", e); + httpServerLogger.error("HTTPServer shutdown Err!", e); } return; } @@ -266,7 +290,7 @@ protected void channelRead0(ChannelHandlerContext ctx, HttpRequest httpRequest) AsyncContext asyncContext = new AsyncContext(requestCommand, responseCommand, asyncContextCompleteHandler); processEventMeshRequest(ctx, asyncContext); } catch (Exception ex) { - logger.error("AbrstractHTTPServer.HTTPHandler.channelRead0 err", ex); + httpServerLogger.error("AbrstractHTTPServer.HTTPHandler.channelRead0 err", ex); } finally { try { decoder.destroy(); @@ -306,7 +330,7 @@ public void processEventMeshRequest(final ChannelHandlerContext ctx, sendResponse(ctx, asyncContext.getResponse().httpResponse()); } catch (Exception e) { - logger.error("process error", e); + httpServerLogger.error("process error", e); } }); } catch (RejectedExecutionException re) { @@ -352,7 +376,7 @@ public void channelActive(ChannelHandlerContext ctx) throws Exception { final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel()); int c = connections.incrementAndGet(); if (c > 20000) { - logger.warn("client|http|channelActive|remoteAddress={}|msg={}", remoteAddress, "too many client(20000) connect " + + httpServerLogger.warn("client|http|channelActive|remoteAddress={}|msg={}", remoteAddress, "too many client(20000) connect " + "this eventMesh server"); ctx.close(); return; @@ -375,7 +399,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc IdleStateEvent event = (IdleStateEvent) evt; if (event.state().equals(IdleState.ALL_IDLE)) { final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel()); - logger.info("client|http|userEventTriggered|remoteAddress={}|msg={}", remoteAddress, evt.getClass() + httpServerLogger.info("client|http|userEventTriggered|remoteAddress={}|msg={}", remoteAddress, evt.getClass() .getName()); ctx.close(); } @@ -398,7 +422,7 @@ protected void initChannel(SocketChannel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); - if(sslContext != null && useTLS){ + if (sslContext != null && useTLS) { SSLEngine sslEngine = sslContext.createSSLEngine(); sslEngine.setUseClientMode(false); pipeline.addFirst("ssl", new SslHandler(sslEngine)); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/AbstractRemotingServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractRemotingServer.java similarity index 97% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/AbstractRemotingServer.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractRemotingServer.java index daeafef665..e3f643629d 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/AbstractRemotingServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractRemotingServer.java @@ -15,17 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.boot; +package org.apache.eventmesh.runtime.boot; + +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicInteger; -import com.webank.eventmesh.common.ThreadUtil; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; + +import org.apache.eventmesh.common.ThreadUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.atomic.AtomicInteger; - public abstract class AbstractRemotingServer { public Logger logger = LoggerFactory.getLogger(this.getClass()); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/EventMeshHTTPServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshHTTPServer.java similarity index 84% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/EventMeshHTTPServer.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshHTTPServer.java index a25c4312cf..80540c0d75 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/EventMeshHTTPServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshHTTPServer.java @@ -15,21 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.boot; - -import com.google.common.eventbus.EventBus; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; -import com.webank.eventmesh.runtime.core.protocol.http.processor.*; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.Client; -import com.webank.eventmesh.runtime.core.protocol.http.producer.ProducerManager; -import com.webank.eventmesh.runtime.core.protocol.http.consumer.ConsumerManager; -import com.webank.eventmesh.runtime.core.protocol.http.push.AbstractHTTPPushRequest; -import com.webank.eventmesh.runtime.core.protocol.http.retry.HttpRetryer; -import com.webank.eventmesh.runtime.common.ServiceState; -import com.webank.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; -import com.webank.eventmesh.runtime.metrics.http.HTTPMetricsServer; -import com.webank.eventmesh.common.ThreadPoolFactory; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; +package org.apache.eventmesh.runtime.boot; import java.util.List; import java.util.concurrent.BlockingQueue; @@ -37,6 +23,29 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; +import com.google.common.eventbus.EventBus; + +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.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; + public class EventMeshHTTPServer extends AbrstractHTTPServer { private EventMeshServer eventMeshServer; @@ -97,23 +106,23 @@ public void initThreadPool() throws Exception { BlockingQueue sendMsgThreadPoolQueue = new LinkedBlockingQueue(eventMeshHttpConfiguration.eventMeshServerSendMsgBlockQSize); sendMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerSendMsgThreadNum, - eventMeshHttpConfiguration.eventMeshServerSendMsgThreadNum, sendMsgThreadPoolQueue, "eventMesh-sendmsg-",true); + eventMeshHttpConfiguration.eventMeshServerSendMsgThreadNum, sendMsgThreadPoolQueue, "eventMesh-sendmsg-", true); BlockingQueue pushMsgThreadPoolQueue = new LinkedBlockingQueue(eventMeshHttpConfiguration.eventMeshServerPushMsgBlockQSize); pushMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerPushMsgThreadNum, - eventMeshHttpConfiguration.eventMeshServerPushMsgThreadNum, pushMsgThreadPoolQueue, "eventMesh-pushmsg-",true); + eventMeshHttpConfiguration.eventMeshServerPushMsgThreadNum, pushMsgThreadPoolQueue, "eventMesh-pushmsg-", true); BlockingQueue clientManageThreadPoolQueue = new LinkedBlockingQueue(eventMeshHttpConfiguration.eventMeshServerClientManageBlockQSize); clientManageExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerClientManageThreadNum, - eventMeshHttpConfiguration.eventMeshServerClientManageThreadNum, clientManageThreadPoolQueue, "eventMesh-clientmanage-",true); + eventMeshHttpConfiguration.eventMeshServerClientManageThreadNum, clientManageThreadPoolQueue, "eventMesh-clientmanage-", true); BlockingQueue adminThreadPoolQueue = new LinkedBlockingQueue(50); adminExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerAdminThreadNum, - eventMeshHttpConfiguration.eventMeshServerAdminThreadNum, adminThreadPoolQueue, "eventMesh-admin-",true); + eventMeshHttpConfiguration.eventMeshServerAdminThreadNum, adminThreadPoolQueue, "eventMesh-admin-", true); BlockingQueue replyMessageThreadPoolQueue = new LinkedBlockingQueue(100); replyMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshHttpConfiguration.eventMeshServerReplyMsgThreadNum, - eventMeshHttpConfiguration.eventMeshServerReplyMsgThreadNum, replyMessageThreadPoolQueue, "eventMesh-replymsg-",true); + eventMeshHttpConfiguration.eventMeshServerReplyMsgThreadNum, replyMessageThreadPoolQueue, "eventMesh-replymsg-", true); } public ThreadPoolExecutor getBatchMsgExecutor() { diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/EventMeshServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java similarity index 76% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/EventMeshServer.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java index 81ad7baeed..61bfb89bdb 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/EventMeshServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java @@ -15,13 +15,12 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.boot; +package org.apache.eventmesh.runtime.boot; -import com.webank.eventmesh.runtime.common.ServiceState; -import com.webank.eventmesh.runtime.configuration.EventMeshTCPConfiguration; -import com.webank.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -//import org.apache.rocketmq.client.impl.consumer.ConsumeMessageConcurrentlyService; +import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; +import org.apache.eventmesh.runtime.configuration.EventMeshTCPConfiguration; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,7 +48,7 @@ public void init() throws Exception { eventMeshHTTPServer = new EventMeshHTTPServer(this, eventMeshHttpConfiguration); eventMeshHTTPServer.init(); eventMeshTCPServer = new EventMeshTCPServer(this, eventMeshTCPConfiguration); - if (eventMeshTCPConfiguration.eventMeshTcpServerEnabled) { + if (eventMeshTCPConfiguration != null && eventMeshTCPConfiguration.eventMeshTcpServerEnabled) { eventMeshTCPServer.init(); } @@ -58,27 +57,27 @@ public void init() throws Exception { // logger.info("load custom {} class for eventMesh", ConsumeMessageConcurrentlyService.class.getCanonicalName()); serviceState = ServiceState.INITED; - logger.info("server state:{}",serviceState); + logger.info("server state:{}", serviceState); } public void start() throws Exception { eventMeshHTTPServer.start(); - if (eventMeshTCPConfiguration.eventMeshTcpServerEnabled) { + if (eventMeshTCPConfiguration != null && eventMeshTCPConfiguration.eventMeshTcpServerEnabled) { eventMeshTCPServer.start(); } serviceState = ServiceState.RUNNING; - logger.info("server state:{}",serviceState); + logger.info("server state:{}", serviceState); } public void shutdown() throws Exception { serviceState = ServiceState.STOPING; - logger.info("server state:{}",serviceState); + logger.info("server state:{}", serviceState); eventMeshHTTPServer.shutdown(); - if (eventMeshTCPConfiguration.eventMeshTcpServerEnabled) { + if (eventMeshTCPConfiguration != null && eventMeshTCPConfiguration.eventMeshTcpServerEnabled) { eventMeshTCPServer.shutdown(); } serviceState = ServiceState.STOPED; - logger.info("server state:{}",serviceState); + logger.info("server state:{}", serviceState); } public EventMeshHTTPServer getEventMeshHTTPServer() { @@ -89,5 +88,7 @@ public EventMeshTCPServer getEventMeshTCPServer() { return eventMeshTCPServer; } - public ServiceState getServiceState() { return serviceState; } + public ServiceState getServiceState() { + return serviceState; + } } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/EventMeshStartup.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshStartup.java similarity index 87% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/EventMeshStartup.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshStartup.java index 8c2a97995d..4ae1191a98 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/EventMeshStartup.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshStartup.java @@ -15,23 +15,23 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.boot; +package org.apache.eventmesh.runtime.boot; -import com.webank.eventmesh.common.config.ConfigurationWraper; -import com.webank.eventmesh.runtime.configuration.EventMeshTCPConfiguration; -import com.webank.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; +import java.io.File; + +import org.apache.eventmesh.common.config.ConfigurationWraper; +import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; +import org.apache.eventmesh.runtime.configuration.EventMeshTCPConfiguration; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; - public class EventMeshStartup { public static Logger logger = LoggerFactory.getLogger(EventMeshStartup.class); public static void main(String[] args) throws Exception { - try{ + try { ConfigurationWraper configurationWraper = new ConfigurationWraper(EventMeshConstants.EVENTMESH_CONF_HOME + File.separator @@ -54,7 +54,7 @@ public static void main(String[] args) throws Exception { logger.error("exception when shutdown...", e); } })); - }catch (Throwable e){ + } catch (Throwable e) { logger.error("EventMesh start fail.", e); e.printStackTrace(); } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/EventMeshTCPServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshTCPServer.java similarity index 77% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/EventMeshTCPServer.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshTCPServer.java index cff186f73d..84454d10b7 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/EventMeshTCPServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshTCPServer.java @@ -15,32 +15,38 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.boot; +package org.apache.eventmesh.runtime.boot; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; import com.google.common.util.concurrent.RateLimiter; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcpConnectionHandler; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcpExceptionHandler; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcpMessageDispatcher; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.group.ClientSessionGroupMapping; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.push.retry.EventMeshTcpRetryer; -import com.webank.eventmesh.runtime.util.EventMeshThreadFactoryImpl; -import com.webank.eventmesh.runtime.admin.controller.ClientManageController; -import com.webank.eventmesh.runtime.configuration.EventMeshTCPConfiguration; -import com.webank.eventmesh.runtime.metrics.tcp.EventMeshTcpMonitor; -import com.webank.eventmesh.common.ThreadPoolFactory; -import com.webank.eventmesh.common.protocol.tcp.codec.Codec; + import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.PooledByteBufAllocator; -import io.netty.channel.*; +import io.netty.channel.AdaptiveRecvByteBufAllocator; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOption; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.timeout.IdleStateHandler; import io.netty.handler.traffic.ChannelTrafficShapingHandler; import io.netty.handler.traffic.GlobalTrafficShapingHandler; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; +import org.apache.eventmesh.common.ThreadPoolFactory; +import org.apache.eventmesh.common.protocol.tcp.codec.Codec; +import org.apache.eventmesh.runtime.admin.controller.ClientManageController; +import org.apache.eventmesh.runtime.configuration.EventMeshTCPConfiguration; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcpConnectionHandler; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcpExceptionHandler; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcpMessageDispatcher; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.group.ClientSessionGroupMapping; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.push.retry.EventMeshTcpRetryer; +import org.apache.eventmesh.runtime.metrics.tcp.EventMeshTcpMonitor; +import org.apache.eventmesh.runtime.util.EventMeshThreadFactoryImpl; public class EventMeshTCPServer extends AbstractRemotingServer { @@ -58,13 +64,53 @@ public class EventMeshTCPServer extends AbstractRemotingServer { private GlobalTrafficShapingHandler globalTrafficShapingHandler; - public static ScheduledExecutorService scheduler; + private ScheduledExecutorService scheduler; + + private ExecutorService taskHandleExecutorService; + + public void setClientSessionGroupMapping(ClientSessionGroupMapping clientSessionGroupMapping) { + this.clientSessionGroupMapping = clientSessionGroupMapping; + } + + public ClientManageController getClientManageController() { + return clientManageController; + } + + public void setClientManageController(ClientManageController clientManageController) { + this.clientManageController = clientManageController; + } + + public ScheduledExecutorService getScheduler() { + return scheduler; + } + + public void setScheduler(ScheduledExecutorService scheduler) { + this.scheduler = scheduler; + } + + public ExecutorService getTaskHandleExecutorService() { + return taskHandleExecutorService; + } + + public void setTaskHandleExecutorService(ExecutorService taskHandleExecutorService) { + this.taskHandleExecutorService = taskHandleExecutorService; + } + + public RateLimiter getRateLimiter() { + return rateLimiter; + } + + public void setRateLimiter(RateLimiter rateLimiter) { + this.rateLimiter = rateLimiter; + } + + private ScheduledFuture tcpRegisterTask; - public static ExecutorService taskHandleExecutorService; + private RateLimiter rateLimiter; - public ScheduledFuture tcpRegisterTask; + private EventMeshTcpMessageDispatcher eventMeshTcpMessageDispatcher = new EventMeshTcpMessageDispatcher(EventMeshTCPServer.this); + private EventMeshTcpExceptionHandler eventMeshTcpExceptionHandler = new EventMeshTcpExceptionHandler(EventMeshTCPServer.this); - public RateLimiter rateLimiter; public EventMeshTCPServer(EventMeshServer eventMeshServer, EventMeshTCPConfiguration eventMeshTCPConfiguration) { @@ -101,8 +147,8 @@ public void initChannel(Channel ch) throws Exception { .addLast(workerGroup, new IdleStateHandler(eventMeshTCPConfiguration.eventMeshTcpIdleReadSeconds, eventMeshTCPConfiguration.eventMeshTcpIdleWriteSeconds, eventMeshTCPConfiguration.eventMeshTcpIdleAllSeconds), - new EventMeshTcpMessageDispatcher(EventMeshTCPServer.this), - new EventMeshTcpExceptionHandler(EventMeshTCPServer.this) + eventMeshTcpMessageDispatcher, + eventMeshTcpExceptionHandler ); } }); @@ -128,7 +174,7 @@ public void initChannel(Channel ch) throws Exception { public void init() throws Exception { logger.info("==================EventMeshTCPServer Initialing=================="); - initThreadPool(); + initThreadPool(); rateLimiter = RateLimiter.create(eventMeshTCPConfiguration.eventMeshTcpMsgReqnumPerSecond); @@ -201,10 +247,11 @@ private void initThreadPool() throws Exception { scheduler = ThreadPoolFactory.createScheduledExecutor(eventMeshTCPConfiguration.eventMeshTcpGlobalScheduler, new EventMeshThreadFactoryImpl("eventMesh-tcp-scheduler", true)); - taskHandleExecutorService = ThreadPoolFactory.createThreadPoolExecutor(eventMeshTCPConfiguration.eventMeshTcpTaskHandleExecutorPoolSize, eventMeshTCPConfiguration.eventMeshTcpTaskHandleExecutorPoolSize, new LinkedBlockingQueue(10000), new EventMeshThreadFactoryImpl("eventMesh-tcp-task-handle", true));; + taskHandleExecutorService = ThreadPoolFactory.createThreadPoolExecutor(eventMeshTCPConfiguration.eventMeshTcpTaskHandleExecutorPoolSize, eventMeshTCPConfiguration.eventMeshTcpTaskHandleExecutorPoolSize, new LinkedBlockingQueue(10000), new EventMeshThreadFactoryImpl("eventMesh-tcp-task-handle", true)); + ; } - private void shutdownThreadPool(){ + private void shutdownThreadPool() { scheduler.shutdown(); taskHandleExecutorService.shutdown(); } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/SSLContextFactory.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/SSLContextFactory.java similarity index 54% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/SSLContextFactory.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/SSLContextFactory.java index 60ffdd3984..529ee37ec9 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/boot/SSLContextFactory.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/SSLContextFactory.java @@ -1,16 +1,35 @@ -package com.webank.eventmesh.runtime.boot; +/* + * 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.boot; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.security.KeyStore; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; + +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SSLContextFactory { private static Logger httpLogger = LoggerFactory.getLogger("http"); @@ -22,16 +41,16 @@ public class SSLContextFactory { private static String pass; - public static SSLContext getSslContext(){ + public static SSLContext getSslContext() { SSLContext sslContext = null; - try{ + try { protocol = System.getProperty("ssl.server.protocol", "TLSv1.1"); - fileName = System.getProperty("ssl.server.cer","sChat2.jks"); + fileName = System.getProperty("ssl.server.cer", "sChat2.jks"); char[] filePass = null; - pass = System.getProperty("ssl.server.pass","sNetty"); - if(StringUtils.isNotBlank(pass)){ + pass = System.getProperty("ssl.server.pass", "sNetty"); + if (StringUtils.isNotBlank(pass)) { filePass = pass.toCharArray(); } sslContext = SSLContext.getInstance(protocol); @@ -42,7 +61,7 @@ public static SSLContext getSslContext(){ KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(keyStore, filePass); sslContext.init(kmf.getKeyManagers(), null, null); - }catch (Exception e){ + } catch (Exception e) { httpLogger.warn("sslContext init failed", e); sslContext = null; } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/common/Pair.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/common/Pair.java similarity index 96% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/common/Pair.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/common/Pair.java index 1d7590523e..5e2a428ef6 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/common/Pair.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/common/Pair.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.common; +package org.apache.eventmesh.runtime.common; public class Pair { private T1 object1; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/common/ServiceState.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/common/ServiceState.java similarity index 95% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/common/ServiceState.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/common/ServiceState.java index 910ce8f489..6848b2c2bc 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/common/ServiceState.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/common/ServiceState.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.common; +package org.apache.eventmesh.runtime.common; public enum ServiceState { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshHTTPConfiguration.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshHTTPConfiguration.java new file mode 100644 index 0000000000..a73c24a7b7 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshHTTPConfiguration.java @@ -0,0 +1,230 @@ +/* + * Licensed 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 com.google.common.util.concurrent.RateLimiter; + +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.config.CommonConfiguration; +import org.apache.eventmesh.common.config.ConfigurationWraper; + +public class EventMeshHTTPConfiguration extends CommonConfiguration { + + public int httpServerPort = 10105; + + public RateLimiter eventMeshServerBatchMsgNumLimiter = RateLimiter.create(20000); + + public boolean eventMeshServerBatchMsgBatchEnabled = Boolean.TRUE; + + public int eventMeshServerBatchMsgThreadNum = 10; + + public int eventMeshServerSendMsgThreadNum = 8; + + public int eventMeshServerPushMsgThreadNum = 8; + + public int eventMeshServerReplyMsgThreadNum = 8; + + public int eventMeshServerClientManageThreadNum = 4; + + public int eventMeshServerRegistryThreadNum = 10; + + public int eventMeshServerAdminThreadNum = 2; + + public int eventMeshServerRetryThreadNum = 2; + + public int eventMeshServerPullRegistryIntervel = 30000; + + public int eventMeshServerAsyncAccumulationThreshold = 1000; + + public int eventMeshServerRetryBlockQSize = 10000; + + public int eventMeshServerBatchBlockQSize = 1000; + + public int eventMeshServerSendMsgBlockQSize = 1000; + + public int eventMeshServerPushMsgBlockQSize = 1000; + + public int eventMeshServerClientManageBlockQSize = 1000; + + public int eventMeshServerBusyCheckIntervel = 1000; + + public boolean eventMeshServerConsumerEnabled = false; + + public boolean eventMeshServerUseTls = false; + + public EventMeshHTTPConfiguration(ConfigurationWraper configurationWraper) { + super(configurationWraper); + } + + @Override + public void init() { + super.init(); + + if (configurationWraper != null) { + String httpServerPortStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_HTTP_PORT); + Preconditions.checkState(StringUtils.isNotEmpty(httpServerPortStr) && StringUtils.isNumeric(httpServerPortStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_HTTP_PORT)); + httpServerPort = Integer.valueOf(StringUtils.deleteWhitespace(httpServerPortStr)); + + String eventMeshServerBatchMsgThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerBatchMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerBatchMsgThreadNumStr)) { + eventMeshServerBatchMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBatchMsgThreadNumStr)); + } + + String eventMeshServerBatchMsgNumLimiterStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_RATELIMITER); + if (StringUtils.isNotEmpty(eventMeshServerBatchMsgNumLimiterStr) && StringUtils.isNumeric(eventMeshServerBatchMsgNumLimiterStr)) { + eventMeshServerBatchMsgNumLimiter = RateLimiter.create(Double.valueOf(StringUtils.deleteWhitespace(eventMeshServerBatchMsgNumLimiterStr))); + } + + String eventMeshServerBatchMsgBatchEnableStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_BATCH_ENABLED); + if (StringUtils.isNotBlank(eventMeshServerBatchMsgBatchEnableStr)) { + eventMeshServerBatchMsgBatchEnabled = Boolean.valueOf(eventMeshServerBatchMsgBatchEnableStr); + } + + String eventMeshServerAsyncAccumulationThresholdStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ASYNC_ACCUMULATION_THRESHOLD); + if (StringUtils.isNotEmpty(eventMeshServerAsyncAccumulationThresholdStr) && StringUtils.isNumeric(eventMeshServerAsyncAccumulationThresholdStr)) { + eventMeshServerAsyncAccumulationThreshold = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerAsyncAccumulationThresholdStr)); + } + + String eventMeshServerSendMsgThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SENDMSG_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerSendMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerSendMsgThreadNumStr)) { + eventMeshServerSendMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerSendMsgThreadNumStr)); + } + + String eventMeshServerReplyMsgThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_REPLYMSG_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerReplyMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerReplyMsgThreadNumStr)) { + eventMeshServerReplyMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerReplyMsgThreadNumStr)); + } + + String eventMeshServerPushMsgThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_PUSHMSG_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerPushMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerPushMsgThreadNumStr)) { + eventMeshServerPushMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPushMsgThreadNumStr)); + } + + String eventMeshServerRegistryThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_REGISTRY_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerRegistryThreadNumStr) && StringUtils.isNumeric(eventMeshServerRegistryThreadNumStr)) { + eventMeshServerRegistryThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRegistryThreadNumStr)); + } + + String eventMeshServerClientManageThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_CLIENTMANAGE_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerClientManageThreadNumStr) && StringUtils.isNumeric(eventMeshServerClientManageThreadNumStr)) { + eventMeshServerClientManageThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageThreadNumStr)); + } + + String eventMeshServerPullRegistryIntervelStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_PULL_REGISTRY_INTERVEL); + if (StringUtils.isNotEmpty(eventMeshServerPullRegistryIntervelStr) && StringUtils.isNumeric(eventMeshServerPullRegistryIntervelStr)) { + eventMeshServerPullRegistryIntervel = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPullRegistryIntervelStr)); + } + + String eventMeshServerAdminThreadNumStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_ADMIN_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerAdminThreadNumStr) && StringUtils.isNumeric(eventMeshServerAdminThreadNumStr)) { + eventMeshServerAdminThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerAdminThreadNumStr)); + } + + String eventMeshServerRetryBlockQSizeStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_RETRY_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerRetryBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerRetryBlockQSizeStr)) { + eventMeshServerRetryBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRetryBlockQSizeStr)); + } + + String eventMeshServerBatchBlockQSizeStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_BATCHMSG_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerBatchBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerBatchBlockQSizeStr)) { + eventMeshServerBatchBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBatchBlockQSizeStr)); + } + + String eventMeshServerSendMsgBlockQSizeStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_SENDMSG_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerSendMsgBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerSendMsgBlockQSizeStr)) { + eventMeshServerSendMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerSendMsgBlockQSizeStr)); + } + + String eventMeshServerPushMsgBlockQSizeStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_PUSHMSG_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerPushMsgBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerPushMsgBlockQSizeStr)) { + eventMeshServerPushMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPushMsgBlockQSizeStr)); + } + + String eventMeshServerClientManageBlockQSizeStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_CLIENTM_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerClientManageBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerClientManageBlockQSizeStr)) { + eventMeshServerClientManageBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageBlockQSizeStr)); + } + + String eventMeshServerBusyCheckIntervelStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_BUSY_CHECK_INTERVEL); + if (StringUtils.isNotEmpty(eventMeshServerBusyCheckIntervelStr) && StringUtils.isNumeric(eventMeshServerBusyCheckIntervelStr)) { + eventMeshServerBusyCheckIntervel = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBusyCheckIntervelStr)); + } + + String eventMeshServerConsumerEnabledStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_CONSUMER_ENABLED); + if (StringUtils.isNotEmpty(eventMeshServerConsumerEnabledStr)) { + eventMeshServerConsumerEnabled = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerConsumerEnabledStr)); + } + + String eventMeshServerRetryThreadNumStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_RETRY_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerRetryThreadNumStr) && StringUtils.isNumeric(eventMeshServerRetryThreadNumStr)) { + eventMeshServerRetryThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRetryThreadNumStr)); + } + + String eventMeshServerUseTlsStr = configurationWraper.getProp(ConfKeys.KEY_EVENTMESH_HTTPS_ENABLED); + if (StringUtils.isNotEmpty(eventMeshServerUseTlsStr)) { + eventMeshServerUseTls = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerUseTlsStr)); + } + } + } + + static class ConfKeys { + + public static String KEYS_EVENTMESH_SERVER_HTTP_PORT = "eventMesh.server.http.port"; + + public static String KEYS_EVENTMESH_BATCHMSG_THREAD_NUM = "eventMesh.server.batchmsg.threads.num"; + + public static String KEYS_EVENTMESH_BATCHMSG_RATELIMITER = "eventMesh.server.batchmsg.speed.ratelimiter"; + + 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_INTERVEL = "eventMesh.server.busy.check.intervel"; + + 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_INTERVEL = "eventMesh.server.pull.registry.intervel"; + + 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_HTTPS_ENABLED = "eventMesh.server.useTls.enabled"; + } +} diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/configuration/EventMeshTCPConfiguration.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshTCPConfiguration.java similarity index 93% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/configuration/EventMeshTCPConfiguration.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshTCPConfiguration.java index 3810c70e02..4f3ddddf5e 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/configuration/EventMeshTCPConfiguration.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshTCPConfiguration.java @@ -15,12 +15,13 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.configuration; +package org.apache.eventmesh.runtime.configuration; import com.google.common.base.Preconditions; -import com.webank.eventmesh.common.config.CommonConfiguration; -import com.webank.eventmesh.common.config.ConfigurationWraper; + import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.config.CommonConfiguration; +import org.apache.eventmesh.common.config.ConfigurationWraper; public class EventMeshTCPConfiguration extends CommonConfiguration { public int eventMeshTcpServerPort = 10000; @@ -75,12 +76,12 @@ public class EventMeshTCPConfiguration extends CommonConfiguration { private TrafficShapingConfig gtc = new TrafficShapingConfig(0, 10_000, 1_000, 2000); private TrafficShapingConfig ctc = new TrafficShapingConfig(0, 2_000, 1_000, 10_000); - public EventMeshTCPConfiguration(ConfigurationWraper configurationWraper){ + public EventMeshTCPConfiguration(ConfigurationWraper configurationWraper) { super(configurationWraper); } @Override - public void init(){ + public void init() { super.init(); String eventMeshTcpServerPortStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_TCP_PORT); Preconditions.checkState(StringUtils.isNotEmpty(eventMeshTcpServerPortStr) && StringUtils.isNumeric(eventMeshTcpServerPortStr), @@ -118,53 +119,53 @@ public void init(){ } String eventMeshTcpGlobalSchedulerStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_GLOBAL_SCHEDULER); - if(StringUtils.isNotEmpty(eventMeshTcpGlobalSchedulerStr)){ + if (StringUtils.isNotEmpty(eventMeshTcpGlobalSchedulerStr)) { Preconditions.checkState(StringUtils.isNumeric(eventMeshTcpGlobalSchedulerStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_GLOBAL_SCHEDULER)); eventMeshTcpGlobalScheduler = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTcpGlobalSchedulerStr)); } String eventMeshTcpTaskHandleExecutorPoolSizeStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_TCP_TASK_HANDLE_POOL_SIZE); - if(StringUtils.isNotEmpty(eventMeshTcpTaskHandleExecutorPoolSizeStr)){ + if (StringUtils.isNotEmpty(eventMeshTcpTaskHandleExecutorPoolSizeStr)) { Preconditions.checkState(StringUtils.isNumeric(eventMeshTcpTaskHandleExecutorPoolSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_TCP_TASK_HANDLE_POOL_SIZE)); eventMeshTcpTaskHandleExecutorPoolSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTcpTaskHandleExecutorPoolSizeStr)); } String eventMeshTcpSessionExpiredInMillsStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_SESSION_EXPIRED_TIME); - if(StringUtils.isNotEmpty(eventMeshTcpSessionExpiredInMillsStr)){ + if (StringUtils.isNotEmpty(eventMeshTcpSessionExpiredInMillsStr)) { Preconditions.checkState(StringUtils.isNumeric(eventMeshTcpSessionExpiredInMillsStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_SESSION_EXPIRED_TIME)); eventMeshTcpSessionExpiredInMills = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTcpSessionExpiredInMillsStr)); } String eventMeshTcpSessionUpstreamBufferSizeStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_SESSION_UPSTREAM_BUFFER_SIZE); - if(StringUtils.isNotEmpty(eventMeshTcpSessionUpstreamBufferSizeStr)){ + if (StringUtils.isNotEmpty(eventMeshTcpSessionUpstreamBufferSizeStr)) { Preconditions.checkState(StringUtils.isNumeric(eventMeshTcpSessionUpstreamBufferSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_SESSION_UPSTREAM_BUFFER_SIZE)); eventMeshTcpSessionUpstreamBufferSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTcpSessionUpstreamBufferSizeStr)); } String eventMeshTcpSessionDownstreamUnackSizeStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_SESSION_DOWNSTREAM_UNACK_SIZE); - if(StringUtils.isNotEmpty(eventMeshTcpSessionDownstreamUnackSizeStr)){ + if (StringUtils.isNotEmpty(eventMeshTcpSessionDownstreamUnackSizeStr)) { Preconditions.checkState(StringUtils.isNumeric(eventMeshTcpSessionDownstreamUnackSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_SESSION_DOWNSTREAM_UNACK_SIZE)); eventMeshTcpSessionDownstreamUnackSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTcpSessionDownstreamUnackSizeStr)); } //========================================eventMesh retry config=============================================// String eventMeshTcpMsgRetryTimesStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_RETRY_PUSH_RETRY_TIMES); - if(StringUtils.isNotEmpty(eventMeshTcpMsgRetryTimesStr)) { + if (StringUtils.isNotEmpty(eventMeshTcpMsgRetryTimesStr)) { Preconditions.checkState(StringUtils.isNumeric(eventMeshTcpMsgRetryTimesStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_RETRY_PUSH_RETRY_TIMES)); eventMeshTcpMsgRetryTimes = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTcpMsgRetryTimesStr)); } String eventMeshTcpMsgRetryDelayInMillsStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_RETRY_PUSH_RETRY_DELAY); - if(StringUtils.isNotEmpty(eventMeshTcpMsgRetryDelayInMillsStr)) { + if (StringUtils.isNotEmpty(eventMeshTcpMsgRetryDelayInMillsStr)) { Preconditions.checkState(StringUtils.isNumeric(eventMeshTcpMsgRetryDelayInMillsStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_RETRY_PUSH_RETRY_DELAY)); eventMeshTcpMsgRetryDelayInMills = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTcpMsgRetryDelayInMillsStr)); } String eventMeshTcpMsgRetryQueueSizeStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_RETRY_PUSH_RETRY_QUEUE_SIZE); - if(StringUtils.isNotEmpty(eventMeshTcpMsgRetryQueueSizeStr)) { + if (StringUtils.isNotEmpty(eventMeshTcpMsgRetryQueueSizeStr)) { Preconditions.checkState(StringUtils.isNumeric(eventMeshTcpMsgRetryQueueSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_RETRY_PUSH_RETRY_QUEUE_SIZE)); eventMeshTcpMsgRetryQueueSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTcpMsgRetryQueueSizeStr)); } @@ -177,7 +178,7 @@ public void init(){ } String eventMeshServerAdminPortStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_ADMIN_HTTP_PORT); - if(StringUtils.isNotEmpty(eventMeshServerAdminPortStr)){ + if (StringUtils.isNotEmpty(eventMeshServerAdminPortStr)) { Preconditions.checkState(StringUtils.isNumeric(eventMeshServerAdminPortStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_ADMIN_HTTP_PORT)); eventMeshServerAdminPort = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerAdminPortStr)); @@ -189,13 +190,13 @@ public void init(){ } String eventMeshTcpPushFailIsolateTimeInMillsStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_PUSH_FAIL_ISOLATE_TIME); - if(StringUtils.isNotEmpty(eventMeshTcpPushFailIsolateTimeInMillsStr)) { + if (StringUtils.isNotEmpty(eventMeshTcpPushFailIsolateTimeInMillsStr)) { Preconditions.checkState(StringUtils.isNumeric(eventMeshTcpPushFailIsolateTimeInMillsStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_PUSH_FAIL_ISOLATE_TIME)); eventMeshTcpPushFailIsolateTimeInMills = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTcpPushFailIsolateTimeInMillsStr)); } String eventMeshTcpDownStreamMapSizeStr = configurationWraper.getProp(ConfKeys.KEYS_EVENTMESH_TCP_DOWNSTREAM_MAP_SIZE); - if(StringUtils.isNotEmpty(eventMeshTcpDownStreamMapSizeStr)) { + if (StringUtils.isNotEmpty(eventMeshTcpDownStreamMapSizeStr)) { Preconditions.checkState(StringUtils.isNumeric(eventMeshTcpDownStreamMapSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_TCP_DOWNSTREAM_MAP_SIZE)); eventMeshTcpDownStreamMapSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTcpDownStreamMapSizeStr)); } @@ -209,7 +210,7 @@ public TrafficShapingConfig getCtc() { return ctc; } - static class ConfKeys{ + static class ConfKeys { public static String KEYS_EVENTMESH_SERVER_TCP_PORT = "eventMesh.server.tcp.port"; public static String KEYS_EVENTMESH_SERVER_READER_IDLE_SECONDS = "eventMesh.server.tcp.readerIdleSeconds"; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/constants/DeFiBusConstant.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/DeFiBusConstant.java similarity index 64% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/constants/DeFiBusConstant.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/DeFiBusConstant.java index 88d35ba863..898854d770 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/constants/DeFiBusConstant.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/DeFiBusConstant.java @@ -1,4 +1,22 @@ -package com.webank.eventmesh.runtime.constants; +/* + * 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.constants; //TODO public class DeFiBusConstant { @@ -16,7 +34,7 @@ public class DeFiBusConstant { public static final String REDIRECT_FLAG = "REDIRECT_FLAG"; - public static final String PLUGIN_CLASS_NAME = "com.webank.defibus.broker.plugin.DeFiPluginMessageStore"; + public static final String PLUGIN_CLASS_NAME = "org.apache.defibus.broker.plugin.DeFiPluginMessageStore"; public static final String RR_REPLY_TOPIC = "rr-reply-topic"; //post fix for reply topic diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/constants/EventMeshConstants.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java similarity index 91% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/constants/EventMeshConstants.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java index eb3f95de3c..d498305e6c 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/constants/EventMeshConstants.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.constants; +package org.apache.eventmesh.runtime.constants; public class EventMeshConstants { @@ -112,4 +112,12 @@ public class EventMeshConstants { 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"; + } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/constants/EventMeshVersion.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshVersion.java similarity index 96% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/constants/EventMeshVersion.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshVersion.java index b58dbc64f7..91cc68475f 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/constants/EventMeshVersion.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshVersion.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.constants; +package org.apache.eventmesh.runtime.constants; public class EventMeshVersion { diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/ConsumerGroupConf.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/ConsumerGroupConf.java similarity index 97% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/ConsumerGroupConf.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/ConsumerGroupConf.java index 509b0beb23..9eda09656a 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/ConsumerGroupConf.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/ConsumerGroupConf.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.consumergroup; - -import com.google.common.collect.Maps; +package org.apache.eventmesh.runtime.core.consumergroup; import java.util.Map; import java.util.Objects; +import com.google.common.collect.Maps; + public class ConsumerGroupConf { //eg . 5013-1A0 private String consumerGroup; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/ConsumerGroupTopicConf.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/ConsumerGroupTopicConf.java similarity index 98% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/ConsumerGroupTopicConf.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/ConsumerGroupTopicConf.java index c1c86b8913..5a16c4c703 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/ConsumerGroupTopicConf.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/ConsumerGroupTopicConf.java @@ -15,18 +15,19 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.consumergroup; - -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.runtime.core.consumergroup; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class ConsumerGroupTopicConf { public static Logger logger = LoggerFactory.getLogger(ConsumerGroupTopicConf.class); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/ProducerGroupConf.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/ProducerGroupConf.java similarity index 96% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/ProducerGroupConf.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/ProducerGroupConf.java index 2f4718789a..8518850cab 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/ProducerGroupConf.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/ProducerGroupConf.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.consumergroup; +package org.apache.eventmesh.runtime.core.consumergroup; import java.util.Objects; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/event/ConsumerGroupInstanceChangeEvent.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/event/ConsumerGroupInstanceChangeEvent.java similarity index 93% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/event/ConsumerGroupInstanceChangeEvent.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/event/ConsumerGroupInstanceChangeEvent.java index fd9f462b4c..f06ba0263a 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/event/ConsumerGroupInstanceChangeEvent.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/event/ConsumerGroupInstanceChangeEvent.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.consumergroup.event; +package org.apache.eventmesh.runtime.core.consumergroup.event; public class ConsumerGroupInstanceChangeEvent { } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/event/ConsumerGroupStateEvent.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/event/ConsumerGroupStateEvent.java similarity index 91% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/event/ConsumerGroupStateEvent.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/event/ConsumerGroupStateEvent.java index 0202d36695..fbf06125d3 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/event/ConsumerGroupStateEvent.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/event/ConsumerGroupStateEvent.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.consumergroup.event; +package org.apache.eventmesh.runtime.core.consumergroup.event; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; public class ConsumerGroupStateEvent { diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/event/ConsumerGroupTopicConfChangeEvent.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/event/ConsumerGroupTopicConfChangeEvent.java similarity index 92% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/event/ConsumerGroupTopicConfChangeEvent.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/event/ConsumerGroupTopicConfChangeEvent.java index d1a3f3b985..7b19ffb041 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/consumergroup/event/ConsumerGroupTopicConfChangeEvent.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/event/ConsumerGroupTopicConfChangeEvent.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.consumergroup.event; +package org.apache.eventmesh.runtime.core.consumergroup.event; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf; public class ConsumerGroupTopicConfChangeEvent { diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/plugin/MQConsumerWrapper.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQConsumerWrapper.java similarity index 91% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/plugin/MQConsumerWrapper.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQConsumerWrapper.java index ded0ba89a4..ad44d3e9b9 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/plugin/MQConsumerWrapper.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQConsumerWrapper.java @@ -15,18 +15,19 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.plugin; +package org.apache.eventmesh.runtime.core.plugin; + +import java.util.List; +import java.util.Properties; +import java.util.ServiceLoader; -import com.webank.eventmesh.api.AbstractContext; -import com.webank.eventmesh.api.consumer.MeshMQPushConsumer; import io.openmessaging.api.AsyncMessageListener; import io.openmessaging.api.Message; -import io.openmessaging.api.MessageListener; + +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.api.consumer.MeshMQPushConsumer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; -import java.util.Properties; -import java.util.ServiceLoader; public class MQConsumerWrapper extends MQWrapper { @@ -52,7 +53,7 @@ public void unsubscribe(String topic) throws Exception { public synchronized void init(Properties keyValue) throws Exception { meshMQPushConsumer = getMeshMQPushConsumer(); - if (meshMQPushConsumer == null){ + if (meshMQPushConsumer == null) { logger.error("can't load the meshMQPushConsumer plugin, please check."); throw new RuntimeException("doesn't load the meshMQPushConsumer plugin, please check."); } @@ -63,7 +64,7 @@ public synchronized void init(Properties keyValue) throws Exception { private MeshMQPushConsumer getMeshMQPushConsumer() { ServiceLoader meshMQPushConsumerServiceLoader = ServiceLoader.load(MeshMQPushConsumer.class); - if (meshMQPushConsumerServiceLoader.iterator().hasNext()){ + if (meshMQPushConsumerServiceLoader.iterator().hasNext()) { return meshMQPushConsumerServiceLoader.iterator().next(); } return null; @@ -88,7 +89,7 @@ public void updateOffset(List msgs, AbstractContext eventMeshConsumeCon meshMQPushConsumer.updateOffset(msgs, eventMeshConsumeConcurrentlyContext); } - public AbstractContext getContext(){ + public AbstractContext getContext() { return meshMQPushConsumer.getContext(); } } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/plugin/MQProducerWrapper.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQProducerWrapper.java similarity index 93% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/plugin/MQProducerWrapper.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQProducerWrapper.java index 26cdc0c4fb..082ab3bc00 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/plugin/MQProducerWrapper.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQProducerWrapper.java @@ -15,31 +15,32 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.plugin; +package org.apache.eventmesh.runtime.core.plugin; + +import java.util.Properties; +import java.util.ServiceLoader; -import com.webank.eventmesh.api.RRCallback; -import com.webank.eventmesh.api.producer.MeshMQProducer; import io.openmessaging.api.Message; import io.openmessaging.api.SendCallback; + +import org.apache.eventmesh.api.RRCallback; +import org.apache.eventmesh.api.producer.MeshMQProducer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Properties; -import java.util.ServiceLoader; - public class MQProducerWrapper extends MQWrapper { public Logger logger = LoggerFactory.getLogger(this.getClass()); protected MeshMQProducer meshMQProducer; - public synchronized void init(Properties keyValue) throws Exception{ + public synchronized void init(Properties keyValue) throws Exception { if (inited.get()) { return; } meshMQProducer = getSpiMeshMQProducer(); - if (meshMQProducer == null){ + if (meshMQProducer == null) { logger.error("can't load the meshMQProducer plugin, please check."); throw new RuntimeException("doesn't load the meshMQProducer plugin, please check."); } @@ -50,7 +51,7 @@ public synchronized void init(Properties keyValue) throws Exception{ private MeshMQProducer getSpiMeshMQProducer() { ServiceLoader meshMQProducerServiceLoader = ServiceLoader.load(MeshMQProducer.class); - if (meshMQProducerServiceLoader.iterator().hasNext()){ + if (meshMQProducerServiceLoader.iterator().hasNext()) { return meshMQProducerServiceLoader.iterator().next(); } return null; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQWrapper.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQWrapper.java new file mode 100644 index 0000000000..f8ae78c112 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/plugin/MQWrapper.java @@ -0,0 +1,46 @@ +/* + * 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.plugin; + +import java.util.concurrent.atomic.AtomicBoolean; + +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; + +public abstract class MQWrapper { + + public static final String EVENT_STORE_ROCKETMQ = "rocketmq"; + + public static final String EVENT_STORE_DEFIBUS = "defibus"; + + public static String CURRENT_EVENT_STORE = EVENT_STORE_DEFIBUS; + + public static final String EVENT_STORE_CONF = System.getProperty(EventMeshConstants.EVENT_STORE_PROPERTIES, System.getenv(EventMeshConstants.EVENT_STORE_ENV)); + + static { + if (StringUtils.isNotBlank(EVENT_STORE_CONF)) { + CURRENT_EVENT_STORE = EVENT_STORE_CONF; + } + } + + public AtomicBoolean started = new AtomicBoolean(Boolean.FALSE); + + public AtomicBoolean inited = new AtomicBoolean(Boolean.FALSE); + +} diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/async/AsyncContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/async/AsyncContext.java similarity index 97% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/async/AsyncContext.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/async/AsyncContext.java index 49895ea171..d081e225ee 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/async/AsyncContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/async/AsyncContext.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.async; - -import com.google.common.base.Preconditions; +package org.apache.eventmesh.runtime.core.protocol.http.async; import java.util.Objects; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.atomic.AtomicBoolean; +import com.google.common.base.Preconditions; + public class AsyncContext { private T request; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/async/CompleteHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/async/CompleteHandler.java similarity index 93% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/async/CompleteHandler.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/async/CompleteHandler.java index eba32d78e6..6faa01f98d 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/async/CompleteHandler.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/async/CompleteHandler.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.async; +package org.apache.eventmesh.runtime.core.protocol.http.async; public interface CompleteHandler { void onResponse(T t); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/consumer/ConsumerGroupManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/ConsumerGroupManager.java similarity index 86% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/consumer/ConsumerGroupManager.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/ConsumerGroupManager.java index d9c2238da2..76381e322e 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/consumer/ConsumerGroupManager.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/ConsumerGroupManager.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.consumer; - -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; +package org.apache.eventmesh.runtime.core.protocol.http.consumer; import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; + public class ConsumerGroupManager { protected AtomicBoolean started = new AtomicBoolean(Boolean.FALSE); @@ -52,7 +52,7 @@ public synchronized void start() throws Exception { } private synchronized void setupEventMeshConsumer(ConsumerGroupConf consumerGroupConfig) throws Exception { - for(String topic:consumerGroupConfig.getConsumerGroupTopicConf().keySet()) { + for (String topic : consumerGroupConfig.getConsumerGroupTopicConf().keySet()) { eventMeshConsumer.subscribe(topic); } } @@ -64,11 +64,11 @@ public synchronized void shutdown() throws Exception { public synchronized void refresh(ConsumerGroupConf consumerGroupConfig) throws Exception { - if(consumerGroupConfig == null || this.consumerGroupConfig.equals(consumerGroupConfig)) { + if (consumerGroupConfig == null || this.consumerGroupConfig.equals(consumerGroupConfig)) { return; } - if(started.get()) { + if (started.get()) { shutdown(); } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/consumer/ConsumerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/ConsumerManager.java similarity index 95% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/consumer/ConsumerManager.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/ConsumerManager.java index f2d361deb4..467e4f0cb5 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/consumer/ConsumerManager.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/ConsumerManager.java @@ -15,26 +15,34 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.consumer; +package org.apache.eventmesh.runtime.core.protocol.http.consumer; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import com.alibaba.fastjson.JSONObject; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf; -import com.webank.eventmesh.runtime.core.consumergroup.event.ConsumerGroupStateEvent; -import com.webank.eventmesh.runtime.core.consumergroup.event.ConsumerGroupTopicConfChangeEvent; import com.google.common.eventbus.Subscribe; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.Client; + import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf; +import org.apache.eventmesh.runtime.core.consumergroup.event.ConsumerGroupStateEvent; +import org.apache.eventmesh.runtime.core.consumergroup.event.ConsumerGroupTopicConfChangeEvent; +import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.Client; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - public class ConsumerManager { private EventMeshHTTPServer eventMeshHTTPServer; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/consumer/EventMeshConsumer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/EventMeshConsumer.java similarity index 91% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/consumer/EventMeshConsumer.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/EventMeshConsumer.java index f83f30cba3..186ca35c35 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/consumer/EventMeshConsumer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/EventMeshConsumer.java @@ -15,29 +15,36 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.consumer; - -import com.webank.eventmesh.api.AbstractContext; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf; -import com.webank.eventmesh.runtime.core.plugin.MQConsumerWrapper; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; -import com.webank.eventmesh.runtime.core.protocol.http.producer.EventMeshProducer; -import com.webank.eventmesh.runtime.core.protocol.http.producer.SendMessageContext; -import com.webank.eventmesh.runtime.core.protocol.http.push.HTTPMessageHandler; -import com.webank.eventmesh.runtime.core.protocol.http.push.MessageHandler; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import io.openmessaging.api.*; -import org.apache.commons.collections4.MapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.runtime.core.protocol.http.consumer; import java.util.List; import java.util.Properties; import java.util.concurrent.atomic.AtomicBoolean; +import io.openmessaging.api.Action; +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 org.apache.commons.collections4.MapUtils; +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf; +import org.apache.eventmesh.runtime.core.plugin.MQConsumerWrapper; +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.core.protocol.http.push.HTTPMessageHandler; +import org.apache.eventmesh.runtime.core.protocol.http.push.MessageHandler; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class EventMeshConsumer { private EventMeshHTTPServer eventMeshHTTPServer; @@ -65,7 +72,7 @@ public EventMeshConsumer(EventMeshHTTPServer eventMeshHTTPServer, ConsumerGroupC this.consumerGroupConf = consumerGroupConf; } - private MessageHandler httpMessageHandler ; + private MessageHandler httpMessageHandler; public synchronized void init() throws Exception { httpMessageHandler = new HTTPMessageHandler(this); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/consumer/HandleMsgContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/HandleMsgContext.java similarity index 94% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/consumer/HandleMsgContext.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/HandleMsgContext.java index 520a1c5c8d..afb27c1515 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/consumer/HandleMsgContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/consumer/HandleMsgContext.java @@ -15,22 +15,23 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.consumer; +package org.apache.eventmesh.runtime.core.protocol.http.consumer; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; -import com.webank.eventmesh.api.AbstractContext; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf; -import com.webank.eventmesh.common.Constants; import io.openmessaging.api.Message; + import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - public class HandleMsgContext { public Logger messageLogger = LoggerFactory.getLogger("message"); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/AdminMetricsProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminMetricsProcessor.java similarity index 83% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/AdminMetricsProcessor.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminMetricsProcessor.java index 35ed2fd0df..dac27461b8 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/AdminMetricsProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminMetricsProcessor.java @@ -15,13 +15,14 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.processor; +package org.apache.eventmesh.runtime.core.protocol.http.processor; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; -import com.webank.eventmesh.common.command.HttpCommand; import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.common.command.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; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/AdminShutdownProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminShutdownProcessor.java similarity index 77% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/AdminShutdownProcessor.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminShutdownProcessor.java index 252cbc04dd..775a7c1730 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/AdminShutdownProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/AdminShutdownProcessor.java @@ -15,18 +15,19 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.processor; - -import com.webank.eventmesh.runtime.boot.EventMeshServer; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.command.HttpCommand; -import com.webank.eventmesh.common.protocol.http.common.EventMeshRetCode; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.runtime.util.RemotingHelper; +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.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.runtime.boot.EventMeshServer; +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.util.RemotingHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageProcessor.java similarity index 92% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageProcessor.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageProcessor.java index 72a9a8caa1..37d28b7d69 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageProcessor.java @@ -15,41 +15,42 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.processor; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; -import com.webank.eventmesh.runtime.core.protocol.http.producer.EventMeshProducer; -import com.webank.eventmesh.runtime.core.protocol.http.producer.SendMessageContext; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.command.HttpCommand; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageBatchRequestBody; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageBatchResponseBody; -import com.webank.eventmesh.common.protocol.http.common.EventMeshRetCode; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.common.protocol.http.header.message.SendMessageBatchRequestHeader; -import com.webank.eventmesh.common.protocol.http.header.message.SendMessageBatchResponseHeader; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.util.RemotingHelper; +package org.apache.eventmesh.runtime.core.protocol.http.processor; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; + 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.common.protocol.http.body.message.SendMessageBatchRequestBody; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchResponseBody; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +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.runtime.boot.EventMeshHTTPServer; +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.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.RemotingHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; - public class BatchSendMessageProcessor implements HttpRequestProcessor { public Logger cmdLogger = LoggerFactory.getLogger("cmd"); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageV2Processor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageV2Processor.java similarity index 92% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageV2Processor.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageV2Processor.java index 8dc33d8284..5dff4082cd 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageV2Processor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/BatchSendMessageV2Processor.java @@ -15,36 +15,37 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.processor; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; -import com.webank.eventmesh.runtime.core.protocol.http.producer.EventMeshProducer; -import com.webank.eventmesh.runtime.core.protocol.http.producer.SendMessageContext; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.command.HttpCommand; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageBatchV2RequestBody; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageBatchV2ResponseBody; -import com.webank.eventmesh.common.protocol.http.common.EventMeshRetCode; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.common.protocol.http.header.message.SendMessageBatchV2RequestHeader; -import com.webank.eventmesh.common.protocol.http.header.message.SendMessageBatchV2ResponseHeader; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.util.RemotingHelper; +package org.apache.eventmesh.runtime.core.protocol.http.processor; + +import java.util.concurrent.TimeUnit; + 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.common.protocol.http.body.message.SendMessageBatchV2RequestBody; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchV2ResponseBody; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +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.runtime.boot.EventMeshHTTPServer; +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.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.RemotingHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.TimeUnit; - public class BatchSendMessageV2Processor implements HttpRequestProcessor { public Logger cmdLogger = LoggerFactory.getLogger("cmd"); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/HeartBeatProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/HeartBeatProcessor.java similarity index 83% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/HeartBeatProcessor.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/HeartBeatProcessor.java index 182f51b2d4..febfa91f48 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/HeartBeatProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/HeartBeatProcessor.java @@ -15,33 +15,37 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.processor; - -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.command.HttpCommand; -import com.webank.eventmesh.common.protocol.http.body.client.HeartbeatRequestBody; -import com.webank.eventmesh.common.protocol.http.body.client.HeartbeatResponseBody; -import com.webank.eventmesh.common.protocol.http.common.EventMeshRetCode; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.common.protocol.http.header.client.HeartbeatRequestHeader; -import com.webank.eventmesh.common.protocol.http.header.client.HeartbeatResponseHeader; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import com.webank.eventmesh.runtime.core.protocol.http.async.CompleteHandler; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.Client; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.util.RemotingHelper; +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.protocol.http.body.client.HeartbeatRequestBody; +import org.apache.eventmesh.common.protocol.http.body.client.HeartbeatResponseBody; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.protocol.http.header.client.HeartbeatRequestHeader; +import org.apache.eventmesh.common.protocol.http.header.client.HeartbeatResponseHeader; +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +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.async.CompleteHandler; +import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.Client; +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.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - public class HeartBeatProcessor implements HttpRequestProcessor { public Logger httpLogger = LoggerFactory.getLogger("http"); @@ -101,7 +105,7 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext String consumerGroup = EventMeshUtil.buildClientGroup(heartbeatRequestHeader.getSys(), heartbeatRequestHeader.getDcn()); List heartbeatEntities = heartbeatRequestBody.getHeartbeatEntities(); - for (HeartbeatRequestBody.HeartbeatEntity heartbeatEntity : heartbeatEntities){ + for (HeartbeatRequestBody.HeartbeatEntity heartbeatEntity : heartbeatEntities) { String topic = heartbeatEntity.topic; String url = heartbeatEntity.url; Client client = new Client(); @@ -117,30 +121,30 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext client.lastUpTime = new Date(); - if (StringUtils.isBlank(client.topic)){ + if (StringUtils.isBlank(client.topic)) { continue; } - if (StringUtils.isBlank(client.url)){ + if (StringUtils.isBlank(client.url)) { continue; } String groupTopicKey = client.consumerGroup + "@" + client.topic; - if (tmp.containsKey(groupTopicKey)){ + if (tmp.containsKey(groupTopicKey)) { tmp.get(groupTopicKey).add(client); - }else { + } else { List clients = new ArrayList<>(); clients.add(client); tmp.put(groupTopicKey, clients); } } - synchronized (eventMeshHTTPServer.localClientInfoMapping){ + synchronized (eventMeshHTTPServer.localClientInfoMapping) { for (Map.Entry> groupTopicClientMapping : tmp.entrySet()) { - List localClientList = eventMeshHTTPServer.localClientInfoMapping.get(groupTopicClientMapping.getKey()); - if (CollectionUtils.isEmpty(localClientList)){ + List localClientList = eventMeshHTTPServer.localClientInfoMapping.get(groupTopicClientMapping.getKey()); + if (CollectionUtils.isEmpty(localClientList)) { eventMeshHTTPServer.localClientInfoMapping.put(groupTopicClientMapping.getKey(), groupTopicClientMapping.getValue()); - }else { + } else { List tmpClientList = groupTopicClientMapping.getValue(); supplyClientInfoList(tmpClientList, localClientList); eventMeshHTTPServer.localClientInfoMapping.put(groupTopicClientMapping.getKey(), localClientList); @@ -185,16 +189,16 @@ public void onResponse(HttpCommand httpCommand) { } private void supplyClientInfoList(List tmpClientList, List localClientList) { - for (Client tmpClient : tmpClientList){ + for (Client tmpClient : tmpClientList) { boolean isContains = false; - for (Client localClient : localClientList){ - if (StringUtils.equals(localClient.url, tmpClient.url)){ + for (Client localClient : localClientList) { + if (StringUtils.equals(localClient.url, tmpClient.url)) { isContains = true; localClient.lastUpTime = tmpClient.lastUpTime; break; } } - if (!isContains){ + if (!isContains) { localClientList.add(tmpClient); } } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/ReplyMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/ReplyMessageProcessor.java similarity index 90% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/ReplyMessageProcessor.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/ReplyMessageProcessor.java index de4cbe9938..3c461edbb2 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/ReplyMessageProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/ReplyMessageProcessor.java @@ -15,40 +15,41 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.processor; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import com.webank.eventmesh.runtime.core.protocol.http.async.CompleteHandler; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; -import com.webank.eventmesh.runtime.core.protocol.http.producer.EventMeshProducer; -import com.webank.eventmesh.runtime.core.protocol.http.producer.SendMessageContext; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.LiteMessage; -import com.webank.eventmesh.common.command.HttpCommand; -import com.webank.eventmesh.common.protocol.http.body.message.ReplyMessageRequestBody; -import com.webank.eventmesh.common.protocol.http.body.message.ReplyMessageResponseBody; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; -import com.webank.eventmesh.common.protocol.http.common.EventMeshRetCode; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.common.protocol.http.header.message.ReplyMessageRequestHeader; -import com.webank.eventmesh.common.protocol.http.header.message.ReplyMessageResponseHeader; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.util.RemotingHelper; +package org.apache.eventmesh.runtime.core.protocol.http.processor; + +import java.util.Map; + 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.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.common.protocol.http.body.message.ReplyMessageRequestBody; +import org.apache.eventmesh.common.protocol.http.body.message.ReplyMessageResponseBody; +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.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.runtime.boot.EventMeshHTTPServer; +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.async.CompleteHandler; +import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; +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.RemotingHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Map; - public class ReplyMessageProcessor implements HttpRequestProcessor { public Logger messageLogger = LoggerFactory.getLogger("message"); @@ -191,9 +192,9 @@ public void onResponse(HttpCommand httpCommand) { } }; - LiteMessage liteMessage = new LiteMessage(replyMessageRequestBody.getBizSeqNo(), - replyMessageRequestBody.getUniqueId(), replyMessageRequestBody.getOrigTopic(), - replyMessageRequestBody.getContent()); +// 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())); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/SendAsyncMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendAsyncMessageProcessor.java similarity index 91% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/SendAsyncMessageProcessor.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendAsyncMessageProcessor.java index 0ba1afe6ec..8fd2fad76d 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/SendAsyncMessageProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendAsyncMessageProcessor.java @@ -15,33 +15,34 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.processor; - -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import com.webank.eventmesh.runtime.core.protocol.http.async.CompleteHandler; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; -import com.webank.eventmesh.runtime.core.protocol.http.producer.EventMeshProducer; -import com.webank.eventmesh.runtime.core.protocol.http.producer.SendMessageContext; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.LiteMessage; -import com.webank.eventmesh.common.command.HttpCommand; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; -import com.webank.eventmesh.common.protocol.http.common.EventMeshRetCode; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.common.protocol.http.header.message.SendMessageRequestHeader; -import com.webank.eventmesh.common.protocol.http.header.message.SendMessageResponseHeader; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.util.RemotingHelper; +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.LiteMessage; +import org.apache.eventmesh.common.command.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.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.runtime.boot.EventMeshHTTPServer; +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.async.CompleteHandler; +import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; +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.RemotingHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/SendSyncMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendSyncMessageProcessor.java similarity index 92% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/SendSyncMessageProcessor.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendSyncMessageProcessor.java index 03b4f46504..d2dacdb552 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/SendSyncMessageProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SendSyncMessageProcessor.java @@ -15,36 +15,38 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.processor; - -import com.webank.eventmesh.api.RRCallback; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import com.webank.eventmesh.runtime.core.protocol.http.async.CompleteHandler; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; -import com.webank.eventmesh.runtime.core.protocol.http.producer.EventMeshProducer; -import com.webank.eventmesh.runtime.core.protocol.http.producer.SendMessageContext; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.LiteMessage; -import com.webank.eventmesh.common.command.HttpCommand; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; -import com.webank.eventmesh.common.protocol.http.common.EventMeshRetCode; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.common.protocol.http.header.message.SendMessageRequestHeader; -import com.webank.eventmesh.common.protocol.http.header.message.SendMessageResponseHeader; -import com.webank.eventmesh.runtime.util.OMSUtil; -import com.webank.eventmesh.runtime.util.EventMeshUtil; +package org.apache.eventmesh.runtime.core.protocol.http.processor; + import com.alibaba.fastjson.JSON; -import com.webank.eventmesh.runtime.util.RemotingHelper; + 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.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 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.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.runtime.boot.EventMeshHTTPServer; +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.async.CompleteHandler; +import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; +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.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/SubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SubscribeProcessor.java similarity index 87% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/SubscribeProcessor.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SubscribeProcessor.java index bc510a3754..54fa73edde 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/SubscribeProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/SubscribeProcessor.java @@ -15,35 +15,42 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.processor; +package org.apache.eventmesh.runtime.core.protocol.http.processor; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; import com.alibaba.fastjson.JSONObject; -import com.webank.eventmesh.common.protocol.http.body.client.SubscribeRequestBody; -import com.webank.eventmesh.common.protocol.http.body.client.SubscribeResponseBody; -import com.webank.eventmesh.common.protocol.http.common.EventMeshRetCode; -import com.webank.eventmesh.common.protocol.http.header.client.SubscribeRequestHeader; -import com.webank.eventmesh.common.protocol.http.header.client.SubscribeResponseHeader; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf; -import com.webank.eventmesh.runtime.core.protocol.http.async.CompleteHandler; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.Client; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.command.HttpCommand; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.util.RemotingHelper; + 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.protocol.http.body.client.SubscribeRequestBody; +import org.apache.eventmesh.common.protocol.http.body.client.SubscribeResponseBody; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.protocol.http.header.client.SubscribeRequestHeader; +import org.apache.eventmesh.common.protocol.http.header.client.SubscribeResponseHeader; +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf; +import org.apache.eventmesh.runtime.core.protocol.http.async.AsyncContext; +import org.apache.eventmesh.runtime.core.protocol.http.async.CompleteHandler; +import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.Client; +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.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; - public class SubscribeProcessor implements HttpRequestProcessor { public Logger httpLogger = LoggerFactory.getLogger("http"); @@ -99,13 +106,13 @@ public void processRequest(ChannelHandlerContext ctx, AsyncContext String consumerGroup = EventMeshUtil.buildClientGroup(subscribeRequestHeader.getSys(), subscribeRequestHeader.getDcn()); - synchronized (eventMeshHTTPServer.localClientInfoMapping){ + synchronized (eventMeshHTTPServer.localClientInfoMapping) { - for (String subTopic : subTopicList){ + for (String subTopic : subTopicList) { List groupTopicClients = eventMeshHTTPServer.localClientInfoMapping.get(consumerGroup + "@" + subTopic); - if (CollectionUtils.isEmpty(groupTopicClients)){ + if (CollectionUtils.isEmpty(groupTopicClients)) { httpLogger.error("group {} topic {} clients is empty", consumerGroup, subTopic); } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/UnSubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/UnSubscribeProcessor.java similarity index 80% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/UnSubscribeProcessor.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/UnSubscribeProcessor.java index 9540eab776..e8707df9d2 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/UnSubscribeProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/UnSubscribeProcessor.java @@ -15,38 +15,46 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.processor; +package org.apache.eventmesh.runtime.core.protocol.http.processor; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import com.alibaba.fastjson.JSONObject; -import com.webank.eventmesh.common.protocol.http.body.client.UnSubscribeRequestBody; -import com.webank.eventmesh.common.protocol.http.body.client.UnSubscribeResponseBody; -import com.webank.eventmesh.common.protocol.http.common.EventMeshRetCode; -import com.webank.eventmesh.common.protocol.http.header.client.UnSubscribeRequestHeader; -import com.webank.eventmesh.common.protocol.http.header.client.UnSubscribeResponseHeader; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; -import com.webank.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf; -import com.webank.eventmesh.runtime.core.consumergroup.event.ConsumerGroupStateEvent; -import com.webank.eventmesh.runtime.core.protocol.http.async.CompleteHandler; -import com.webank.eventmesh.runtime.core.protocol.http.consumer.ConsumerGroupManager; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.Client; -import com.webank.eventmesh.runtime.core.protocol.http.processor.inf.HttpRequestProcessor; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.command.HttpCommand; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.util.RemotingHelper; + 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.protocol.http.body.client.UnSubscribeRequestBody; +import org.apache.eventmesh.common.protocol.http.body.client.UnSubscribeResponseBody; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.protocol.http.header.client.UnSubscribeRequestHeader; +import org.apache.eventmesh.common.protocol.http.header.client.UnSubscribeResponseHeader; +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupConf; +import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupTopicConf; +import org.apache.eventmesh.runtime.core.consumergroup.event.ConsumerGroupStateEvent; +import org.apache.eventmesh.runtime.core.protocol.http.async.AsyncContext; +import org.apache.eventmesh.runtime.core.protocol.http.async.CompleteHandler; +import org.apache.eventmesh.runtime.core.protocol.http.consumer.ConsumerGroupManager; +import org.apache.eventmesh.runtime.core.protocol.http.processor.inf.Client; +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.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - public class UnSubscribeProcessor implements HttpRequestProcessor { public Logger httpLogger = LoggerFactory.getLogger("http"); @@ -231,37 +239,4 @@ public void onResponse(HttpCommand httpCommand) { public boolean rejectRequest() { return false; } - - /** - * notify ConsumerManager 组级别 - */ - private void notifyConsumerManager(String consumerGroup, ConsumerGroupConf latestConsumerGroupConfig, - ConcurrentHashMap localConsumerGroupMapping) throws Exception { - ConsumerGroupManager cgm = eventMeshHTTPServer.getConsumerManager().getConsumer(consumerGroup); - if (cgm == null) { - ConsumerGroupStateEvent notification = new ConsumerGroupStateEvent(); - notification.action = ConsumerGroupStateEvent.ConsumerGroupStateAction.NEW; - notification.consumerGroup = consumerGroup; - notification.consumerGroupConfig = latestConsumerGroupConfig; - eventMeshHTTPServer.getEventBus().post(notification); - return; - } - - if (!latestConsumerGroupConfig.equals(cgm.getConsumerGroupConfig())) { - ConsumerGroupStateEvent notification = new ConsumerGroupStateEvent(); - notification.action = ConsumerGroupStateEvent.ConsumerGroupStateAction.CHANGE; - notification.consumerGroup = consumerGroup; - notification.consumerGroupConfig = latestConsumerGroupConfig; - eventMeshHTTPServer.getEventBus().post(notification); - return; - } - - if (latestConsumerGroupConfig == null) { - ConsumerGroupStateEvent notification = new ConsumerGroupStateEvent(); - notification.action = ConsumerGroupStateEvent.ConsumerGroupStateAction.DELETE; - notification.consumerGroup = consumerGroup; - eventMeshHTTPServer.getEventBus().post(notification); - } - return; - } } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/inf/Client.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/inf/Client.java similarity index 72% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/inf/Client.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/inf/Client.java index 393ea6cf6c..4387509e10 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/inf/Client.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/inf/Client.java @@ -1,9 +1,28 @@ -package com.webank.eventmesh.runtime.core.protocol.http.processor.inf; +/* + * 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.http.processor.inf; + +import java.util.Date; import com.alibaba.fastjson.JSONObject; -import org.apache.commons.lang3.StringUtils; -import java.util.Date; +import org.apache.commons.lang3.StringUtils; public class Client { diff --git a/eventmesh-runtime/src/main/java/com/webank/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 similarity index 85% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/processor/inf/HttpRequestProcessor.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/inf/HttpRequestProcessor.java index ddc2d443cc..cafddac0ff 100644 --- a/eventmesh-runtime/src/main/java/com/webank/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 @@ -15,12 +15,13 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.processor.inf; +package org.apache.eventmesh.runtime.core.protocol.http.processor.inf; -import com.webank.eventmesh.runtime.core.protocol.http.async.AsyncContext; -import com.webank.eventmesh.common.command.HttpCommand; import io.netty.channel.ChannelHandlerContext; +import org.apache.eventmesh.common.command.HttpCommand; +import org.apache.eventmesh.runtime.core.protocol.http.async.AsyncContext; + public interface HttpRequestProcessor { void processRequest(final ChannelHandlerContext ctx, final AsyncContext asyncContext) diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/producer/EventMeshProducer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/EventMeshProducer.java similarity index 92% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/producer/EventMeshProducer.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/EventMeshProducer.java index c2853dd796..c5806daddf 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/producer/EventMeshProducer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/EventMeshProducer.java @@ -15,21 +15,22 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.producer; +package org.apache.eventmesh.runtime.core.protocol.http.producer; + +import java.util.Properties; +import java.util.concurrent.atomic.AtomicBoolean; -import com.webank.eventmesh.api.RRCallback; -import com.webank.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; -import com.webank.eventmesh.runtime.core.consumergroup.ProducerGroupConf; -import com.webank.eventmesh.runtime.core.plugin.MQProducerWrapper; -import com.webank.eventmesh.runtime.util.EventMeshUtil; import io.openmessaging.api.Message; import io.openmessaging.api.SendCallback; + +import org.apache.eventmesh.api.RRCallback; +import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; +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; -import java.util.concurrent.atomic.AtomicBoolean; - public class EventMeshProducer { protected AtomicBoolean started = new AtomicBoolean(Boolean.FALSE); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/producer/ProducerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/ProducerManager.java similarity index 94% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/producer/ProducerManager.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/ProducerManager.java index 96c16da8d9..7e66dab935 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/producer/ProducerManager.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/ProducerManager.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.producer; +package org.apache.eventmesh.runtime.core.protocol.http.producer; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.core.consumergroup.ProducerGroupConf; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +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()); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/producer/SendMessageContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/SendMessageContext.java similarity index 94% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/producer/SendMessageContext.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/SendMessageContext.java index 38ac9b3681..be368b4386 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/producer/SendMessageContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/SendMessageContext.java @@ -15,23 +15,24 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.producer; +package org.apache.eventmesh.runtime.core.protocol.http.producer; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.core.protocol.http.retry.RetryContext; -import com.webank.eventmesh.common.Constants; 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.time.DateFormatUtils; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +import org.apache.eventmesh.runtime.core.protocol.http.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"); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/AbstractHTTPPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/AbstractHTTPPushRequest.java similarity index 89% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/AbstractHTTPPushRequest.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/AbstractHTTPPushRequest.java index 622d81c86a..e7294b837c 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/AbstractHTTPPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/AbstractHTTPPushRequest.java @@ -15,24 +15,25 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.push; - -import com.webank.eventmesh.runtime.core.protocol.http.consumer.HandleMsgContext; -import com.webank.eventmesh.runtime.core.protocol.http.retry.HttpRetryer; -import com.webank.eventmesh.runtime.core.protocol.http.retry.RetryContext; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.webank.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.google.common.collect.Lists; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.RandomUtils; +package org.apache.eventmesh.runtime.core.protocol.http.push; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; +import com.google.common.collect.Lists; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.RandomUtils; +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.http.consumer.HandleMsgContext; +import org.apache.eventmesh.runtime.core.protocol.http.retry.HttpRetryer; +import org.apache.eventmesh.runtime.core.protocol.http.retry.RetryContext; + public abstract class AbstractHTTPPushRequest extends RetryContext { public EventMeshHTTPServer eventMeshHTTPServer; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/AsyncHTTPPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/AsyncHTTPPushRequest.java similarity index 92% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/AsyncHTTPPushRequest.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/AsyncHTTPPushRequest.java index da1e195870..af71ce837b 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/AsyncHTTPPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/AsyncHTTPPushRequest.java @@ -15,26 +15,35 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.push; - -import com.webank.eventmesh.runtime.core.protocol.http.consumer.HandleMsgContext; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; -import com.webank.eventmesh.common.protocol.http.common.ClientRetCode; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.runtime.util.OMSUtil; +package org.apache.eventmesh.runtime.core.protocol.http.push; + +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 com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONObject; import com.google.common.collect.Sets; -import org.apache.commons.lang3.RandomStringUtils; + import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.commons.text.RandomStringGenerator; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.IPUtil; +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.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.http.consumer.HandleMsgContext; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.apache.eventmesh.runtime.util.OMSUtil; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.NameValuePair; @@ -46,14 +55,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -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; - public class AsyncHTTPPushRequest extends AbstractHTTPPushRequest { public Logger messageLogger = LoggerFactory.getLogger("message"); @@ -66,6 +67,9 @@ public class AsyncHTTPPushRequest extends AbstractHTTPPushRequest { public String currPushUrl; + private final static RandomStringGenerator randomGenerator = new RandomStringGenerator.Builder() + .withinRange('0', '9').build(); + public AsyncHTTPPushRequest(HandleMsgContext handleMsgContext, Map> waitingRequests) { super(handleMsgContext); this.waitingRequests = waitingRequests; @@ -112,12 +116,12 @@ public void tryHTTPRequest() { List body = new ArrayList(); body.add(new BasicNameValuePair(PushMessageRequestBody.CONTENT, content)); if (StringUtils.isBlank(handleMsgContext.getBizSeqNo())) { - body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, RandomStringUtils.randomNumeric(20))); + body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, randomGenerator.generate(20))); } else { body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, handleMsgContext.getBizSeqNo())); } if (StringUtils.isBlank(handleMsgContext.getUniqueId())) { - body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, RandomStringUtils.randomNumeric(20))); + body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, randomGenerator.generate(20))); } else { body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, handleMsgContext.getUniqueId())); } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/HTTPClientPool.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/HTTPClientPool.java similarity index 96% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/HTTPClientPool.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/HTTPClientPool.java index 45a71f24bd..c2480f92da 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/HTTPClientPool.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/HTTPClientPool.java @@ -15,17 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.push; +package org.apache.eventmesh.runtime.core.protocol.http.push; + +import java.util.Iterator; +import java.util.List; 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(); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/HTTPMessageHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/HTTPMessageHandler.java similarity index 93% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/HTTPMessageHandler.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/HTTPMessageHandler.java index 7d5d0e3738..f0e0ee87f7 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/HTTPMessageHandler.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/HTTPMessageHandler.java @@ -15,16 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.push; - -import com.webank.eventmesh.runtime.core.protocol.http.consumer.HandleMsgContext; -import com.webank.eventmesh.runtime.core.protocol.http.consumer.EventMeshConsumer; -import com.webank.eventmesh.common.ThreadPoolFactory; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import org.apache.commons.collections4.MapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.runtime.core.protocol.http.push; import java.util.Map; import java.util.Set; @@ -33,6 +24,16 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +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.http.consumer.EventMeshConsumer; +import org.apache.eventmesh.runtime.core.protocol.http.consumer.HandleMsgContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class HTTPMessageHandler implements MessageHandler { public Logger logger = LoggerFactory.getLogger(this.getClass()); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/MessageHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/MessageHandler.java similarity index 87% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/MessageHandler.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/MessageHandler.java index 7eb4c84420..403ed8e3f5 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/push/MessageHandler.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/MessageHandler.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.push; +package org.apache.eventmesh.runtime.core.protocol.http.push; -import com.webank.eventmesh.runtime.core.protocol.http.consumer.HandleMsgContext; +import org.apache.eventmesh.runtime.core.protocol.http.consumer.HandleMsgContext; public interface MessageHandler { boolean handle(HandleMsgContext handleMsgContext); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/retry/DelayRetryable.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/retry/DelayRetryable.java similarity index 93% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/retry/DelayRetryable.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/retry/DelayRetryable.java index 5a6ad814f8..194322576a 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/retry/DelayRetryable.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/retry/DelayRetryable.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.retry; +package org.apache.eventmesh.runtime.core.protocol.http.retry; import java.util.concurrent.Delayed; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/retry/HttpRetryer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/retry/HttpRetryer.java similarity index 95% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/retry/HttpRetryer.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/retry/HttpRetryer.java index 931153b0be..6147f7b3d6 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/retry/HttpRetryer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/retry/HttpRetryer.java @@ -15,11 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.retry; - -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.runtime.core.protocol.http.retry; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.DelayQueue; @@ -28,6 +24,10 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class HttpRetryer { private Logger retryLogger = LoggerFactory.getLogger("retry"); @@ -81,7 +81,7 @@ public void run() { pool.execute(() -> { try { delayRetryable.retry(); - if(retryLogger.isDebugEnabled()) { + if (retryLogger.isDebugEnabled()) { retryLogger.debug("retryObj : {}", delayRetryable); } } catch (Exception e) { diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/retry/RetryContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/retry/RetryContext.java similarity index 96% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/retry/RetryContext.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/retry/RetryContext.java index 6c9717cff4..7841cca1e4 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/http/retry/RetryContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/retry/RetryContext.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.http.retry; +package org.apache.eventmesh.runtime.core.protocol.http.retry; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcp2Client.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcp2Client.java similarity index 72% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcp2Client.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcp2Client.java index 2a22648fe6..17868c6e97 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcp2Client.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcp2Client.java @@ -15,44 +15,45 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client; - -import com.webank.eventmesh.runtime.core.protocol.tcp.client.group.ClientSessionGroupMapping; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.SessionState; -import com.webank.eventmesh.runtime.util.RemotingHelper; -import com.webank.eventmesh.runtime.util.Utils; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.RedirectInfo; -import com.webank.eventmesh.runtime.metrics.tcp.EventMeshTcpMonitor; +package org.apache.eventmesh.runtime.core.protocol.tcp.client; + +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; +import org.apache.eventmesh.common.protocol.tcp.RedirectInfo; +import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; +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.core.protocol.tcp.client.session.SessionState; +import org.apache.eventmesh.runtime.metrics.tcp.EventMeshTcpMonitor; +import org.apache.eventmesh.runtime.util.RemotingHelper; +import org.apache.eventmesh.runtime.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.net.InetSocketAddress; -import java.util.concurrent.TimeUnit; - -import static com.webank.eventmesh.common.protocol.tcp.Command.REDIRECT_TO_CLIENT; -import static com.webank.eventmesh.common.protocol.tcp.Command.SERVER_GOODBYE_REQUEST; - public class EventMeshTcp2Client { private static final Logger logger = LoggerFactory.getLogger(EventMeshTcp2Client.class); - public static InetSocketAddress serverGoodby2Client(Session session, ClientSessionGroupMapping mapping) { + public static InetSocketAddress serverGoodby2Client(EventMeshTCPServer eventMeshTCPServer,Session session, ClientSessionGroupMapping mapping) { logger.info("serverGoodby2Client client[{}]", session.getClient()); - try{ + try { long startTime = System.currentTimeMillis(); Package msg = new Package(); msg.setHeader(new Header(SERVER_GOODBYE_REQUEST, OPStatus.SUCCESS.getCode(), "graceful normal quit from eventmesh", null)); - EventMeshTCPServer.scheduler.submit(new Runnable() { + eventMeshTCPServer.getScheduler().submit(new Runnable() { @Override public void run() { long taskExecuteTime = System.currentTimeMillis(); @@ -61,23 +62,24 @@ public void run() { }); InetSocketAddress address = (InetSocketAddress) session.getContext().channel().remoteAddress(); - closeSessionIfTimeout(session, mapping); + closeSessionIfTimeout(eventMeshTCPServer,session, mapping); return address; - }catch (Exception e){ + } catch (Exception e) { logger.error("exception occur while serverGoodby2Client", e); return null; } } - public static InetSocketAddress goodBye2Client(Session session, + public static InetSocketAddress goodBye2Client(EventMeshTCPServer eventMeshTCPServer, + Session session, String errMsg, int eventMeshStatus, ClientSessionGroupMapping mapping) { try { long startTime = System.currentTimeMillis(); Package msg = new Package(); - msg.setHeader(new Header(SERVER_GOODBYE_REQUEST, eventMeshStatus, errMsg,null)); - EventMeshTCPServer.scheduler.schedule(new Runnable() { + msg.setHeader(new Header(SERVER_GOODBYE_REQUEST, eventMeshStatus, errMsg, null)); + eventMeshTCPServer.getScheduler().schedule(new Runnable() { @Override public void run() { long taskExecuteTime = System.currentTimeMillis(); @@ -85,7 +87,7 @@ public void run() { } }, 1 * 1000, TimeUnit.MILLISECONDS); - closeSessionIfTimeout(session, mapping); + closeSessionIfTimeout(eventMeshTCPServer,session, mapping); return session.getRemoteAddress(); } catch (Exception e) { @@ -118,7 +120,7 @@ public void operationComplete(ChannelFuture future) throws Exception { ); } - public static String redirectClient2NewEventMesh(String newEventMeshIp, int port, Session session, ClientSessionGroupMapping mapping) { + 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(); @@ -127,14 +129,14 @@ public static String redirectClient2NewEventMesh(String newEventMeshIp, int port pkg.setHeader(new Header(REDIRECT_TO_CLIENT, OPStatus.SUCCESS.getCode(), null, null)); pkg.setBody(new RedirectInfo(newEventMeshIp, port)); - EventMeshTCPServer.scheduler.schedule(new Runnable() { + eventMeshTCPServer.getScheduler().schedule(new Runnable() { @Override public void run() { long taskExecuteTime = System.currentTimeMillis(); Utils.writeAndFlush(pkg, startTime, taskExecuteTime, session.getContext(), session); } }, 5 * 1000, TimeUnit.MILLISECONDS); - closeSessionIfTimeout(session, mapping); + closeSessionIfTimeout(eventMeshTCPServer,session, mapping); return session.getRemoteAddress() + "--->" + newEventMeshIp + ":" + port; } catch (Exception e) { logger.error("exception occur while redirectClient2NewEventMesh", e); @@ -142,12 +144,12 @@ public void run() { } } - public static void closeSessionIfTimeout(Session session, ClientSessionGroupMapping mapping) { - EventMeshTCPServer.scheduler.schedule(new Runnable() { + public static void closeSessionIfTimeout(EventMeshTCPServer eventMeshTCPServer,Session session, ClientSessionGroupMapping mapping) { + eventMeshTCPServer.getScheduler().schedule(new Runnable() { @Override public void run() { try { - if(!session.getSessionState().equals(SessionState.CLOSED)){ + if (!session.getSessionState().equals(SessionState.CLOSED)) { mapping.closeSession(session.getContext()); logger.info("closeSessionIfTimeout success, session[{}]", session.getClient()); } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpConnectionHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpConnectionHandler.java similarity index 95% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpConnectionHandler.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpConnectionHandler.java index 29bbcd3ff2..f091ac41aa 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpConnectionHandler.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpConnectionHandler.java @@ -15,19 +15,20 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client; +package org.apache.eventmesh.runtime.core.protocol.tcp.client; + +import java.util.concurrent.atomic.AtomicInteger; -import com.webank.eventmesh.runtime.util.RemotingHelper; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.timeout.IdleState; import io.netty.handler.timeout.IdleStateEvent; + +import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.util.RemotingHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.atomic.AtomicInteger; - public class EventMeshTcpConnectionHandler extends ChannelDuplexHandler { public static AtomicInteger connections = new AtomicInteger(0); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpExceptionHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpExceptionHandler.java similarity index 82% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpExceptionHandler.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpExceptionHandler.java index 0cd0a0b0de..d6ed12a30f 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpExceptionHandler.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpExceptionHandler.java @@ -15,14 +15,15 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client; +package org.apache.eventmesh.runtime.core.protocol.tcp.client; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.common.protocol.tcp.OPStatus; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,7 +49,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E } if (session != null) { - EventMeshTcp2Client.goodBye2Client(session, errMsg, OPStatus.FAIL.getCode(), eventMeshTCPServer.getClientSessionGroupMapping()); + EventMeshTcp2Client.goodBye2Client(eventMeshTCPServer, session, errMsg, OPStatus.FAIL.getCode(), eventMeshTCPServer.getClientSessionGroupMapping()); } else { EventMeshTcp2Client.goodBye2Client(ctx, errMsg, eventMeshTCPServer.getClientSessionGroupMapping(), eventMeshTCPServer.getEventMeshTcpMonitor()); } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpMessageDispatcher.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpMessageDispatcher.java similarity index 83% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpMessageDispatcher.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpMessageDispatcher.java index 7ffc4bc4d4..cbe74f4a2e 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpMessageDispatcher.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/EventMeshTcpMessageDispatcher.java @@ -15,24 +15,25 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client; +package org.apache.eventmesh.runtime.core.protocol.tcp.client; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.SessionState; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.task.GoodbyeTask; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.task.HeartBeatTask; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.task.HelloTask; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.task.ListenTask; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.task.MessageAckTask; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.task.MessageTransferTask; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.task.SubscribeTask; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.task.UnSubscribeTask; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; + +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.runtime.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.SessionState; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.task.GoodbyeTask; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.task.HeartBeatTask; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.task.HelloTask; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.task.ListenTask; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.task.MessageAckTask; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.task.MessageTransferTask; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.task.SubscribeTask; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.task.UnSubscribeTask; +import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,6 +46,7 @@ public class EventMeshTcpMessageDispatcher extends SimpleChannelInboundHandler

paramValues = new ArrayList(); paramValues.add("msg"); paramValues.add(JSON.toJSONString(msg)); @@ -740,14 +753,16 @@ private String pushMsgToEventMesh(Message msg, String ip, int port) { "UTF-8", 3000); } catch (Exception e) { - throw new RuntimeException("httpPost " + targetUrl + " is fail," + e); + logger.error("httpPost " + targetUrl + " is fail,", e); + //throw new RuntimeException("httpPost " + targetUrl + " is fail," , e); + throw e; } if (200 == result.code && result.content != null) { return result.content; } else { - throw new RuntimeException("httpPost targetUrl[" + targetUrl + "] is not OK when getContentThroughHttp, httpResult: " + result + "."); + throw new Exception("httpPost targetUrl[" + targetUrl + "] is not OK when getContentThroughHttp, httpResult: " + result + "."); } } @@ -755,12 +770,12 @@ public MQConsumerWrapper getPersistentMsgConsumer() { return persistentMsgConsumer; } - private void sendMsgBackToBroker(Message msg, String bizSeqNo){ + private void sendMsgBackToBroker(Message msg, String bizSeqNo) throws Exception { try { String topic = msg.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION); - logger.warn("send msg back to broker, bizSeqno:{}, topic:{}",bizSeqNo, topic); + logger.warn("send msg back to broker, bizSeqno:{}, topic:{}", bizSeqNo, topic); - send(new UpStreamMsgContext(null,null, msg), new SendCallback() { + send(new UpStreamMsgContext(null, null, msg), new SendCallback() { @Override public void onSuccess(SendResult sendResult) { logger.info("consumerGroup:{} consume fail, sendMessageBack success, bizSeqno:{}, topic:{}", groupName, bizSeqNo, topic); @@ -777,8 +792,9 @@ public void onException(OnExceptionContext context) { // } }); eventMeshTcpMonitor.getEventMesh2mqMsgNum().incrementAndGet(); - }catch (Exception e){ + } catch (Exception e) { logger.warn("try send msg back to broker failed"); + throw e; } } } diff --git a/eventmesh-runtime/src/main/java/com/webank/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 similarity index 82% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/group/ClientSessionGroupMapping.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/ClientSessionGroupMapping.java index 7beb4d18b2..a33baf1b19 100644 --- a/eventmesh-runtime/src/main/java/com/webank/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 @@ -15,36 +15,43 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.group; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.group.dispatch.FreePriorityDispatchStrategy; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.SessionState; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.push.ClientAckContext; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.push.DownStreamMsgContext; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcp2Client; -import com.webank.eventmesh.common.ThreadUtil; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import com.webank.eventmesh.runtime.util.RemotingHelper; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.group; + +import java.lang.ref.WeakReference; +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + 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.tcp.UserAgent; +import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcp2Client; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.group.dispatch.DownstreamDispatchStrategy; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.group.dispatch.FreePriorityDispatchStrategy; +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.eventmesh.runtime.core.protocol.tcp.client.session.push.ClientAckContext; +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.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.lang.ref.WeakReference; -import java.net.InetSocketAddress; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - public class ClientSessionGroupMapping { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -88,13 +95,13 @@ public Session createSession(UserAgent user, ChannelHandlerContext ctx) throws E user.setHost(addr.getHostString()); user.setPort(addr.getPort()); Session session = null; - if(!sessionTable.containsKey(addr)){ + if (!sessionTable.containsKey(addr)) { logger.info("createSession client[{}]", RemotingHelper.parseChannelRemoteAddr(ctx.channel())); session = new Session(user, ctx, eventMeshTCPServer.getEventMeshTCPConfiguration()); initClientGroupWrapper(user, session); sessionTable.put(addr, session); sessionLogger.info("session|open|succeed|user={}", user); - }else { + } else { session = sessionTable.get(addr); sessionLogger.error("session|open|failed|user={}|msg={}", user, "session has been created!"); } @@ -142,7 +149,7 @@ private void closeSession(Session session) throws Exception { } //session must be synchronized to avoid SessionState be confound, for example adding subscribe when session closing - synchronized (session){ + synchronized (session) { if (SessionState.CLOSED == session.getSessionState()) { logger.info("session has been closed in sync, addr:{}", remoteAddress); @@ -153,9 +160,9 @@ private void closeSession(Session session) throws Exception { if (EventMeshConstants.PURPOSE_SUB.equals(session.getClient().getPurpose())) { cleanClientGroupWrapperByCloseSub(session); - }else if (EventMeshConstants.PURPOSE_PUB.equals(session.getClient().getPurpose())) { + } else if (EventMeshConstants.PURPOSE_PUB.equals(session.getClient().getPurpose())) { cleanClientGroupWrapperByClosePub(session); - }else{ + } else { logger.error("client purpose config is error:{}", session.getClient().getPurpose()); } @@ -172,17 +179,24 @@ public void operationComplete(ChannelFuture future) throws Exception { } } - private void initClientGroupWrapper(UserAgent user, Session session) throws Exception { + private ClientGroupWrapper constructClientGroupWrapper(String sysId, String dcn, + EventMeshTCPServer eventMeshTCPServer, + DownstreamDispatchStrategy downstreamDispatchStrategy) { + return new ClientGroupWrapper(sysId, dcn + , eventMeshTCPServer, downstreamDispatchStrategy); + } + + private void initClientGroupWrapper(UserAgent user, Session session) throws Exception { final String clientGroup = EventMeshUtil.buildClientGroup(user.getSubsystem(), user.getDcn()); - if(!lockMap.containsKey(clientGroup)){ + if (!lockMap.containsKey(clientGroup)) { Object obj = lockMap.putIfAbsent(clientGroup, new Object()); - if(obj == null) { + if (obj == null) { logger.info("add lock to map for group:{}", clientGroup); } } synchronized (lockMap.get(clientGroup)) { if (!clientGroupMap.containsKey(clientGroup)) { - ClientGroupWrapper cgw = new ClientGroupWrapper(user.getSubsystem(), user.getDcn() + ClientGroupWrapper cgw = constructClientGroupWrapper(user.getSubsystem(), user.getDcn() , eventMeshTCPServer, new FreePriorityDispatchStrategy()); clientGroupMap.put(clientGroup, cgw); logger.info("create new ClientGroupWrapper,group:{}", clientGroup); @@ -190,11 +204,11 @@ private void initClientGroupWrapper(UserAgent user, Session session) throws Exc ClientGroupWrapper cgw = clientGroupMap.get(clientGroup); - if (EventMeshConstants.PURPOSE_PUB.equals(user.getPurpose())){ + if (EventMeshConstants.PURPOSE_PUB.equals(user.getPurpose())) { startClientGroupProducer(cgw, session); - }else if (EventMeshConstants.PURPOSE_SUB.equals(user.getPurpose())) { + } else if (EventMeshConstants.PURPOSE_SUB.equals(user.getPurpose())) { initClientGroupConsumser(cgw); - }else{ + } else { logger.error("unknown client purpose:{}", user.getPurpose()); throw new Exception("client purpose config is error"); } @@ -208,7 +222,7 @@ private void startClientGroupProducer(ClientGroupWrapper cgw, Session session) t cgw.startClientGroupProducer(); } boolean flag = cgw.addGroupProducerSession(session); - if(!flag){ + if (!flag) { throw new Exception("addGroupProducerSession fail"); } session.setSessionState(SessionState.RUNNING); @@ -230,7 +244,7 @@ private void initClientGroupConsumser(ClientGroupWrapper cgw) throws Exception { private void startClientGroupConsumer(Session session) throws Exception { final String clientGroup = EventMeshUtil.buildClientGroup(session.getClient().getSubsystem(), session.getClient().getDcn()); - if(!lockMap.containsKey(clientGroup)){ + if (!lockMap.containsKey(clientGroup)) { lockMap.putIfAbsent(clientGroup, new Object()); } synchronized (lockMap.get(clientGroup)) { @@ -238,7 +252,7 @@ private void startClientGroupConsumer(Session session) throws Exception { ClientGroupWrapper cgw = session.getClientGroupWrapper().get(); boolean flag = cgw.addGroupConsumerSession(session); - if(!flag){ + if (!flag) { throw new Exception("addGroupConsumerSession fail"); } @@ -283,22 +297,22 @@ private void cleanSubscriptionInSession(Session session) throws Exception { * * @param session */ - private void handleUnackMsgsInSession(Session session){ + private void handleUnackMsgsInSession(Session session) { ConcurrentHashMap unAckMsg = session.getPusher().getPushContext().getUnAckMsg(); - if(unAckMsg.size() > 0 && session.getClientGroupWrapper().get().getGroupConsumerSessions().size() > 0){ - for(Map.Entry entry : unAckMsg.entrySet()){ + if (unAckMsg.size() > 0 && session.getClientGroupWrapper().get().getGroupConsumerSessions().size() > 0) { + for (Map.Entry entry : unAckMsg.entrySet()) { ClientAckContext ackContext = entry.getValue(); - if(EventMeshUtil.isBroadcast(ackContext.getMsgs().get(0).getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION))){ - logger.warn("exist broadcast msg unack when closeSession,seq:{},bizSeq:{},client:{}",ackContext.getSeq(), EventMeshUtil.getMessageBizSeq(ackContext.getMsgs().get(0)),session.getClient()); + if (EventMeshUtil.isBroadcast(ackContext.getMsgs().get(0).getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION))) { + logger.warn("exist broadcast msg unack when closeSession,seq:{},bizSeq:{},client:{}", ackContext.getSeq(), EventMeshUtil.getMessageBizSeq(ackContext.getMsgs().get(0)), session.getClient()); continue; } - List list = new ArrayList(session.getClientGroupWrapper().get().getGroupConsumerSessions()); + List list = new ArrayList<>(session.getClientGroupWrapper().get().getGroupConsumerSessions()); Collections.shuffle(list); - DownStreamMsgContext downStreamMsgContext= new DownStreamMsgContext(ackContext.getMsgs().get(0),list.get(0),ackContext.getConsumer(), ackContext.getContext(), false); + DownStreamMsgContext downStreamMsgContext = new DownStreamMsgContext(ackContext.getMsgs().get(0), list.get(0), ackContext.getConsumer(), ackContext.getContext(), false); downStreamMsgContext.delay(0L); eventMeshTCPServer.getEventMeshTcpRetryer().pushRetry(downStreamMsgContext); - logger.warn("rePush msg form unAckMsgs,seq:{},rePushSeq:{},rePushClient:{}",entry.getKey(), downStreamMsgContext.seq, downStreamMsgContext.session.getClient()); + logger.warn("rePush msg form unAckMsgs,seq:{},rePushSeq:{},rePushClient:{}", entry.getKey(), downStreamMsgContext.seq, downStreamMsgContext.session.getClient()); } } } @@ -338,7 +352,7 @@ private void shutdownClientGroupProducer(Session session) throws Exception { } private void initSessionCleaner() { - EventMeshTCPServer.scheduler.scheduleAtFixedRate(new Runnable() { + eventMeshTCPServer.getScheduler().scheduleAtFixedRate(new Runnable() { @Override public void run() { Iterator sessionIterator = sessionTable.values().iterator(); @@ -358,7 +372,7 @@ public void run() { } private void initSessionAckContextCleaner() { - eventMeshTCPServer.scheduler.scheduleAtFixedRate(new Runnable() { + eventMeshTCPServer.getScheduler().scheduleAtFixedRate(new Runnable() { @Override public void run() { Iterator sessionIterator = sessionTable.values().iterator(); @@ -381,7 +395,7 @@ public void run() { } private void initDownStreamMsgContextCleaner() { - EventMeshTCPServer.scheduler.scheduleAtFixedRate(new Runnable() { + eventMeshTCPServer.getScheduler().scheduleAtFixedRate(new Runnable() { @Override public void run() { Iterator cgwIterator = clientGroupMap.values().iterator(); @@ -419,7 +433,7 @@ public void shutdown() throws Exception { logger.info("begin to close sessions gracefully"); sessionTable.values().parallelStream().forEach(itr -> { try { - EventMeshTcp2Client.serverGoodby2Client(itr, this); + EventMeshTcp2Client.serverGoodby2Client(this.eventMeshTCPServer,itr, this); } catch (Exception e) { logger.error("say goodbye to session error! {}", itr, e); } @@ -455,11 +469,11 @@ public HashMap statDCNSystemInfoByPurpose(String purpose) HashMap result = new HashMap(); if (!sessionTable.isEmpty()) { for (Session session : sessionTable.values()) { - if(!StringUtils.equals(session.getClient().getPurpose(), purpose)){ + if (!StringUtils.equals(session.getClient().getPurpose(), purpose)) { continue; } - String key = session.getClient().getDcn() + "|" + session.getClient().getSubsystem()+ "|" + purpose; + String key = session.getClient().getDcn() + "|" + session.getClient().getSubsystem() + "|" + purpose; if (!result.containsKey(key)) { result.put(key, new AtomicInteger(1)); } else { @@ -470,15 +484,15 @@ public HashMap statDCNSystemInfoByPurpose(String purpose) return result; } - public Map> prepareEventMeshClientDistributionData(){ + public Map> prepareEventMeshClientDistributionData() { 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/com/webank/eventmesh/runtime/core/protocol/tcp/client/group/dispatch/DownstreamDispatchStrategy.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/dispatch/DownstreamDispatchStrategy.java similarity index 88% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/group/dispatch/DownstreamDispatchStrategy.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/dispatch/DownstreamDispatchStrategy.java index f1cfa63123..27169ff47a 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/group/dispatch/DownstreamDispatchStrategy.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/dispatch/DownstreamDispatchStrategy.java @@ -15,16 +15,17 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.group.dispatch; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.group.dispatch; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; - import java.util.Set; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; + public interface DownstreamDispatchStrategy { /** * 选择一个SESSION + * * @param group * @param consumeSessions * @return diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/group/dispatch/FreePriorityDispatchStrategy.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/dispatch/FreePriorityDispatchStrategy.java similarity index 87% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/group/dispatch/FreePriorityDispatchStrategy.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/dispatch/FreePriorityDispatchStrategy.java index a6ad47d251..77971583ca 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/group/dispatch/FreePriorityDispatchStrategy.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/dispatch/FreePriorityDispatchStrategy.java @@ -15,26 +15,26 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.group.dispatch; - -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.group.dispatch; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class FreePriorityDispatchStrategy implements DownstreamDispatchStrategy { private static final Logger logger = LoggerFactory.getLogger(FreePriorityDispatchStrategy.class); @Override public Session select(String group, String topic, Set groupConsumerSessions) { - if(CollectionUtils.isEmpty(groupConsumerSessions) + if (CollectionUtils.isEmpty(groupConsumerSessions) || StringUtils.isBlank(topic) || StringUtils.isBlank(group)) { return null; @@ -46,7 +46,7 @@ public Session select(String group, String topic, Set groupConsumerSess if (!session.isAvailable(topic)) { continue; } - if(session.isDownStreamBusy()){ + if (session.isDownStreamBusy()) { canDownSessions.add(session); continue; } @@ -54,11 +54,11 @@ public Session select(String group, String topic, Set groupConsumerSess } if (CollectionUtils.isEmpty(filtered)) { - if(CollectionUtils.isEmpty(canDownSessions)){ + if (CollectionUtils.isEmpty(canDownSessions)) { logger.warn("all sessions can't downstream msg"); return null; - }else{ - logger.warn("all sessions are busy,group:{},topic:{}",group,topic); + } else { + logger.warn("all sessions are busy,group:{},topic:{}", group, topic); filtered.addAll(canDownSessions); } } diff --git a/eventmesh-runtime/src/main/java/com/webank/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 similarity index 87% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/Session.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/Session.java index 135d4b0cd8..223974fe95 100644 --- a/eventmesh-runtime/src/main/java/com/webank/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 @@ -15,38 +15,39 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.session; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.push.DownStreamMsgContext; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.push.SessionPusher; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.send.SessionSender; -import com.webank.eventmesh.runtime.util.Utils; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.send.EventMeshTcpSendResult; -import com.webank.eventmesh.runtime.configuration.EventMeshTCPConfiguration; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.group.ClientGroupWrapper; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import com.webank.eventmesh.runtime.util.RemotingHelper; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.session; + +import static org.apache.eventmesh.common.protocol.tcp.Command.LISTEN_RESPONSE; + +import java.lang.ref.WeakReference; +import java.net.InetSocketAddress; +import java.util.List; +import java.util.concurrent.locks.ReentrantLock; + 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.common.Constants; +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.UserAgent; +import org.apache.eventmesh.runtime.configuration.EventMeshTCPConfiguration; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.group.ClientGroupWrapper; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.push.DownStreamMsgContext; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.push.SessionPusher; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.send.EventMeshTcpSendResult; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.send.SessionSender; +import org.apache.eventmesh.runtime.util.RemotingHelper; +import org.apache.eventmesh.runtime.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.lang.ref.WeakReference; -import java.net.InetSocketAddress; -import java.util.List; -import java.util.concurrent.locks.ReentrantLock; - -import static com.webank.eventmesh.common.protocol.tcp.Command.LISTEN_RESPONSE; - public class Session { protected final Logger messageLogger = LoggerFactory.getLogger("message"); @@ -207,7 +208,7 @@ public boolean isCanDownStream() { return pusher.isCanDownStream(); } - public boolean isIsolated(){ + public boolean isIsolated() { return System.currentTimeMillis() < isolateTime; } @@ -223,7 +224,7 @@ public void write2Client(final Package pkg) { public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { messageLogger.error("write2Client fail, pkg[{}] session[{}]", pkg, this); - }else{ + } else { clientGroupWrapper.get().getEventMeshTcpMonitor().getEventMesh2clientMsgNum().incrementAndGet(); } } @@ -332,20 +333,27 @@ public void setIsolateTime(long isolateTime) { this.isolateTime = isolateTime; } - public boolean isAvailable(String topic){ - if(SessionState.CLOSED == sessionState){ + public boolean isAvailable(String topic) { + if (SessionState.CLOSED == sessionState) { logger.warn("session is not available because session has been closed"); return false; } - if(!sessionContext.subscribeTopics.containsKey(topic)){ - logger.warn("session is not available because session has not subscribe topic:{}",topic); + if (!sessionContext.subscribeTopics.containsKey(topic)) { + logger.warn("session is not available because session has not subscribe topic:{}", topic); return false; } - if(isIsolated()){ - logger.warn("session is not available because session is isolated,isolateTime:{}",isolateTime); + if (isIsolated()) { + logger.warn("session is not available because session is isolated,isolateTime:{}", isolateTime); return false; } return true; } + + @Override + public int hashCode() { + int code = 37 + (client != null ? client.hashCode() : 0) + (context != null ? context.hashCode() : 0) + + (sessionState != null ? sessionState.hashCode() : 0); + return code; + } } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/SessionContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/SessionContext.java similarity index 92% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/SessionContext.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/SessionContext.java index 19365503b6..9d5b22e639 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/SessionContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/SessionContext.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.session; - -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import org.apache.commons.lang3.time.DateFormatUtils; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.session; import java.util.concurrent.ConcurrentHashMap; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; + public class SessionContext { private Session session; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/SessionState.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/SessionState.java similarity index 93% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/SessionState.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/SessionState.java index 0c7445f28e..2093a8e4e0 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/SessionState.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/SessionState.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.session; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.session; public enum SessionState { CREATED, diff --git a/eventmesh-runtime/src/main/java/com/webank/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 similarity index 90% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/push/ClientAckContext.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/ClientAckContext.java index c0d1c8a24c..0f322d96e4 100644 --- a/eventmesh-runtime/src/main/java/com/webank/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 @@ -15,21 +15,22 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.session.push; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.push; + +import java.util.List; -import com.webank.eventmesh.api.AbstractContext; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.plugin.MQConsumerWrapper; import io.openmessaging.api.Message; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.plugin.MQConsumerWrapper; +import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; - public class ClientAckContext { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -109,8 +110,8 @@ public void ackMsg() { // 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))); - }else{ - logger.warn("ackMsg failed,consumer is null:{}, context is null:{} , msgs is null:{}",consumer == null, context == null, msgs == null); + } else { + logger.warn("ackMsg failed,consumer is null:{}, context is null:{} , msgs is null:{}", consumer == null, context == null, msgs == null); } } diff --git a/eventmesh-runtime/src/main/java/com/webank/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 similarity index 89% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/push/DownStreamMsgContext.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/DownStreamMsgContext.java index db3ae09268..06d088de96 100644 --- a/eventmesh-runtime/src/main/java/com/webank/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 @@ -15,24 +15,25 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.session.push; - -import com.webank.eventmesh.api.AbstractContext; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.util.ServerGlobal; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.plugin.MQConsumerWrapper; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import io.openmessaging.api.Message; -import org.apache.commons.lang3.time.DateFormatUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.push; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; +import io.openmessaging.api.Message; + +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.plugin.MQConsumerWrapper; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; +import org.apache.eventmesh.runtime.util.ServerGlobal; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class DownStreamMsgContext implements Delayed { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -86,8 +87,8 @@ public void ackMsg() { // ((ConsumeMessageConcurrentlyService)consumeMessageService).updateOffset(msgs, consumeConcurrentlyContext); logger.info("ackMsg topic:{}, bizSeq:{}", msgs.get(0).getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION), msgs.get(0).getSystemProperties(EventMeshConstants.PROPERTY_MESSAGE_KEYS)); - }else{ - logger.warn("ackMsg failed,consumer is null:{}, context is null:{} , msgs is null:{}",consumer == null, consumeConcurrentlyContext == null, msgExt == null); + } else { + logger.warn("ackMsg failed,consumer is null:{}, context is null:{} , msgs is null:{}", consumer == null, consumeConcurrentlyContext == null, msgExt == null); } } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/push/PushContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/PushContext.java similarity index 90% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/push/PushContext.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/PushContext.java index 604a0058fc..fbe5ac90bd 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/push/PushContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/PushContext.java @@ -15,19 +15,21 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.session.push; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.push; + +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicLong; -import com.webank.eventmesh.api.AbstractContext; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.plugin.MQConsumerWrapper; import io.openmessaging.api.Message; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.plugin.MQConsumerWrapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicLong; public class PushContext { @@ -58,7 +60,7 @@ public void deliverFailMsgCount() { } public void unAckMsg(String seq, List msg, AbstractContext context, MQConsumerWrapper consumer) { - ClientAckContext ackContext = new ClientAckContext(seq,context, msg, consumer); + ClientAckContext ackContext = new ClientAckContext(seq, context, msg, consumer); unAckMsg.put(seq, ackContext); logger.info("put msg in unAckMsg,seq:{},unAckMsgSize:{}", seq, getTotalUnackMsgs()); } @@ -72,7 +74,7 @@ public void ackMsg(String seq) { unAckMsg.get(seq).ackMsg(); unAckMsg.remove(seq); ackedMsgsCount.incrementAndGet(); - }else{ + } else { logger.warn("ackMsg failed,the seq:{} is not in unAckMsg map", seq); } } diff --git a/eventmesh-runtime/src/main/java/com/webank/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 similarity index 89% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/push/SessionPusher.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/SessionPusher.java index 2f4a2e7936..49c27a457b 100644 --- a/eventmesh-runtime/src/main/java/com/webank/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 @@ -15,26 +15,27 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.session.push; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.push; + +import java.util.ArrayList; +import java.util.List; + import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.openmessaging.api.Message; + +import org.apache.eventmesh.common.Constants; +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.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.util.EventMeshUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; - public class SessionPusher { private final Logger messageLogger = LoggerFactory.getLogger("message"); @@ -134,10 +135,10 @@ public void operationComplete(ChannelFuture future) throws Exception { session.getClientGroupWrapper().get().getEventMeshTcpRetryer().pushRetry(downStreamMsgContext); } else { pushContext.deliveredMsgCount(); - logger.info("downstreamMsg success,seq:{}, retryTimes:{}, bizSeq:{}", downStreamMsgContext.seq,downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt)); + logger.info("downstreamMsg success,seq:{}, retryTimes:{}, bizSeq:{}", downStreamMsgContext.seq, downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt)); session.getClientGroupWrapper().get().getDownstreamMap().remove(downStreamMsgContext.seq); - if(session.isIsolated()){ + if (session.isIsolated()) { logger.info("cancel isolated,client:{}", session.getClient()); session.setIsolateTime(System.currentTimeMillis()); } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/push/retry/EventMeshTcpRetryer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/retry/EventMeshTcpRetryer.java similarity index 85% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/push/retry/EventMeshTcpRetryer.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/retry/EventMeshTcpRetryer.java index 83173c64ee..c3d0cceb77 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/push/retry/EventMeshTcpRetryer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/push/retry/EventMeshTcpRetryer.java @@ -15,21 +15,8 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.session.push.retry; - -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.util.EventMeshThreadFactoryImpl; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.runtime.constants.DeFiBusConstant; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.push.DownStreamMsgContext; -//import com.webank.eventmesh.connector.defibus.common.Constants; -import io.openmessaging.api.Message; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.push.retry; + import java.util.ArrayList; import java.util.List; import java.util.concurrent.ArrayBlockingQueue; @@ -37,6 +24,19 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import io.openmessaging.api.Message; + +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; +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.push.DownStreamMsgContext; +import org.apache.eventmesh.runtime.util.EventMeshThreadFactoryImpl; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class EventMeshTcpRetryer { public static Logger logger = LoggerFactory.getLogger(EventMeshTcpRetryer.class); @@ -49,7 +49,7 @@ public class EventMeshTcpRetryer { 3, 60000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1000), - new EventMeshThreadFactoryImpl("eventMesh-tcp-retry",true), + new EventMeshThreadFactoryImpl("eventMesh-tcp-retry", true), new ThreadPoolExecutor.AbortPolicy()); private Thread dispatcher; @@ -82,7 +82,7 @@ public void pushRetry(DownStreamMsgContext downStreamMsgContext) { } retrys.offer(downStreamMsgContext); - logger.info("pushRetry success,seq:{}, retryTimes:{}, bizSeq:{}",downStreamMsgContext.seq, downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt)); + logger.info("pushRetry success,seq:{}, retryTimes:{}, bizSeq:{}", downStreamMsgContext.seq, downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt)); } public void init() { @@ -106,11 +106,11 @@ public void run() { logger.info("EventMeshTcpRetryer inited......"); } - private void retryHandle(DownStreamMsgContext downStreamMsgContext){ + private void retryHandle(DownStreamMsgContext downStreamMsgContext) { try { - logger.info("retry downStream msg start,seq:{},retryTimes:{},bizSeq:{}",downStreamMsgContext.seq, downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt)); + logger.info("retry downStream msg start,seq:{},retryTimes:{},bizSeq:{}", downStreamMsgContext.seq, downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt)); - if(isRetryMsgTimeout(downStreamMsgContext)){ + if (isRetryMsgTimeout(downStreamMsgContext)) { return; } downStreamMsgContext.retryTimes++; @@ -118,17 +118,17 @@ private void retryHandle(DownStreamMsgContext downStreamMsgContext){ Session rechoosen = null; String topic = downStreamMsgContext.msgExt.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION); - if(!EventMeshUtil.isBroadcast(topic)){ + if (!EventMeshUtil.isBroadcast(topic)) { rechoosen = downStreamMsgContext.session.getClientGroupWrapper() .get().getDownstreamDispatchStrategy().select(downStreamMsgContext.session.getClientGroupWrapper().get().getGroupName() , topic , downStreamMsgContext.session.getClientGroupWrapper().get().getGroupConsumerSessions()); - }else{ + } else { rechoosen = downStreamMsgContext.session; } - if(rechoosen == null){ + if (rechoosen == null) { logger.warn("retry, found no session to downstream msg,seq:{}, retryTimes:{}, bizSeq:{}", downStreamMsgContext.seq, downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt)); // //需要手动ack掉没有下发成功的消息 @@ -143,13 +143,13 @@ private void retryHandle(DownStreamMsgContext downStreamMsgContext){ // //TODO 将消息推给其它eventMesh,待定 // sendMsgToOtherEventMesh(finalDownStreamMsgContext.msgExt, bizSeqNo, uniqueId); // } - }else { + } else { downStreamMsgContext.session = rechoosen; if (rechoosen.isCanDownStream()) { rechoosen.downstreamMsg(downStreamMsgContext); - logger.info("retry downStream msg end,seq:{},retryTimes:{},bizSeq:{}",downStreamMsgContext.seq, downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt)); - }else{ + logger.info("retry downStream msg end,seq:{},retryTimes:{},bizSeq:{}", downStreamMsgContext.seq, downStreamMsgContext.retryTimes, EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt)); + } else { logger.warn("session is busy,push retry again,seq:{}, session:{}, bizSeq:{}", downStreamMsgContext.seq, downStreamMsgContext.session.getClient(), EventMeshUtil.getMessageBizSeq(downStreamMsgContext.msgExt)); long delayTime = EventMeshUtil.isService(topic) ? 0 : eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpMsgRetryDelayInMills; downStreamMsgContext.delay(delayTime); @@ -161,15 +161,15 @@ private void retryHandle(DownStreamMsgContext downStreamMsgContext){ } } - private boolean isRetryMsgTimeout(DownStreamMsgContext downStreamMsgContext){ - boolean flag =false; + private boolean isRetryMsgTimeout(DownStreamMsgContext downStreamMsgContext) { + boolean flag = false; long ttl = Long.parseLong(downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.PROPERTY_MESSAGE_TTL)); //TODO 关注是否能取到 - long storeTimestamp = Long.parseLong(downStreamMsgContext.msgExt.getUserProperties(DeFiBusConstant.STORE_TIME)); - String leaveTimeStr = downStreamMsgContext.msgExt.getUserProperties(DeFiBusConstant.LEAVE_TIME); + long storeTimestamp = Long.parseLong(downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.STORE_TIME)); + String leaveTimeStr = downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.LEAVE_TIME); long brokerCost = StringUtils.isNumeric(leaveTimeStr) ? Long.parseLong(leaveTimeStr) - storeTimestamp : 0; - String arriveTimeStr = downStreamMsgContext.msgExt.getUserProperties(DeFiBusConstant.ARRIVE_TIME); + String arriveTimeStr = downStreamMsgContext.msgExt.getUserProperties(EventMeshConstants.ARRIVE_TIME); long accessCost = StringUtils.isNumeric(arriveTimeStr) ? System.currentTimeMillis() - Long.parseLong(arriveTimeStr) : 0; double elapseTime = brokerCost + accessCost; if (elapseTime >= ttl) { @@ -190,7 +190,7 @@ public void shutdown() { logger.info("EventMeshTcpRetryer shutdown......"); } - public int getRetrySize(){ + public int getRetrySize() { return retrys.size(); } @@ -199,17 +199,17 @@ public int getRetrySize(){ * * @param downStreamMsgContext */ - private void eventMeshAckMsg(DownStreamMsgContext 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), + logger.warn("eventMeshAckMsg topic:{}, seq:{}, bizSeq:{}", downStreamMsgContext.msgExt.getSystemProperties(Constants.PROPERTY_MESSAGE_DESTINATION), downStreamMsgContext.seq, downStreamMsgContext.msgExt.getSystemProperties(EventMeshConstants.PROPERTY_MESSAGE_KEYS)); downStreamMsgContext.consumer.updateOffset(msgExts, downStreamMsgContext.consumeConcurrentlyContext); // ConsumeMessageService consumeMessageService = downStreamMsgContext.consumer.getDefaultMQPushConsumer().getDefaultMQPushConsumerImpl().getConsumeMessageService(); // ((ConsumeMessageConcurrentlyService)consumeMessageService).updateOffset(msgExts, downStreamMsgContext.consumeConcurrentlyContext); } - public void printRetryThreadPoolState(){ + public void printRetryThreadPoolState() { // ThreadPoolHelper.printState(pool); } } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/send/EventMeshTcpSendResult.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/EventMeshTcpSendResult.java similarity index 96% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/send/EventMeshTcpSendResult.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/EventMeshTcpSendResult.java index 59b38e4b50..61c4d041e4 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/send/EventMeshTcpSendResult.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/EventMeshTcpSendResult.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.session.send; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.send; public class EventMeshTcpSendResult { diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/send/EventMeshTcpSendStatus.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/EventMeshTcpSendStatus.java similarity index 93% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/send/EventMeshTcpSendStatus.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/EventMeshTcpSendStatus.java index 664c88637b..75d0823630 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/send/EventMeshTcpSendStatus.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/EventMeshTcpSendStatus.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.session.send; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.send; public enum EventMeshTcpSendStatus { SUCCESS, diff --git a/eventmesh-runtime/src/main/java/com/webank/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 similarity index 86% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/send/SessionSender.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/SessionSender.java index 6c5427b7b1..e75241cc20 100644 --- a/eventmesh-runtime/src/main/java/com/webank/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 @@ -15,28 +15,29 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.session.send; - -import com.webank.eventmesh.api.RRCallback; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.util.Utils; -import com.webank.eventmesh.runtime.constants.DeFiBusConstant; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.send; + +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; + import io.openmessaging.api.Message; import io.openmessaging.api.SendCallback; + import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.api.RRCallback; +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.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.apache.eventmesh.runtime.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.Semaphore; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; public class SessionSender { @@ -65,7 +66,7 @@ public Semaphore getUpstreamBuff() { return upstreamBuff; } - private Semaphore upstreamBuff ; + private Semaphore upstreamBuff; public SessionSender(Session session) { this.session = session; @@ -79,13 +80,13 @@ public EventMeshTcpSendResult send(Header header, Message msg, SendCallback send UpStreamMsgContext upStreamMsgContext = null; Command cmd = header.getCommand(); if (Command.REQUEST_TO_SERVER == cmd) { - long ttl = msg.getSystemProperties(DeFiBusConstant.PROPERTY_MESSAGE_TTL) != null ? Long.parseLong(msg.getSystemProperties(DeFiBusConstant.PROPERTY_MESSAGE_TTL)) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS; + 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(header.getSeq(), session, msg); session.getClientGroupWrapper().get().request(upStreamMsgContext, sendCallback, initSyncRRCallback(header, startTime, taskExecuteTime), ttl); } else if (Command.RESPONSE_TO_SERVER == cmd) { - String cluster = msg.getUserProperties(DeFiBusConstant.PROPERTY_MESSAGE_CLUSTER); + String cluster = msg.getUserProperties(EventMeshConstants.PROPERTY_MESSAGE_CLUSTER); if (!StringUtils.isEmpty(cluster)) { - String replyTopic = DeFiBusConstant.RR_REPLY_TOPIC; + String replyTopic = EventMeshConstants.RR_REPLY_TOPIC; replyTopic = cluster + "-" + replyTopic; msg.getSystemProperties().put(Constants.PROPERTY_MESSAGE_DESTINATION, replyTopic); } @@ -105,12 +106,12 @@ public EventMeshTcpSendResult send(Header header, Message msg, SendCallback send session.getClientGroupWrapper().get().getEventMeshTcpMonitor().getEventMesh2mqMsgNum().incrementAndGet(); } else { - logger.warn("send too fast,session flow control,session:{}",session.getClient()); + logger.warn("send too fast,session flow control,session:{}", session.getClient()); return new EventMeshTcpSendResult(header.getSeq(), EventMeshTcpSendStatus.SEND_TOO_FAST, EventMeshTcpSendStatus.SEND_TOO_FAST.name()); } } catch (Exception e) { logger.warn("SessionSender send failed", e); - if(!(e instanceof InterruptedException)) { + if (!(e instanceof InterruptedException)) { upstreamBuff.release(); } failMsgCount.incrementAndGet(); diff --git a/eventmesh-runtime/src/main/java/com/webank/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 similarity index 88% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/session/send/UpStreamMsgContext.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/send/UpStreamMsgContext.java index fa320855a8..1618ce72da 100644 --- a/eventmesh-runtime/src/main/java/com/webank/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 @@ -15,13 +15,14 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.session.send; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.session.send; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; import io.openmessaging.api.Message; + import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; public class UpStreamMsgContext { diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/AbstractTask.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/AbstractTask.java similarity index 86% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/AbstractTask.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/AbstractTask.java index 1122cf3e6b..64e0eefb5b 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/AbstractTask.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/AbstractTask.java @@ -15,12 +15,13 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.task; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.task; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.common.protocol.tcp.Package; import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/eventmesh-runtime/src/main/java/com/webank/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 similarity index 75% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/GoodbyeTask.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/GoodbyeTask.java index 235598f4bc..67c0d5cf84 100644 --- a/eventmesh-runtime/src/main/java/com/webank/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 @@ -15,18 +15,19 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.task; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.task; + +import static org.apache.eventmesh.common.protocol.tcp.Command.CLIENT_GOODBYE_RESPONSE; -import com.webank.eventmesh.runtime.util.Utils; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcp2Client; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; import io.netty.channel.ChannelHandlerContext; -import static com.webank.eventmesh.common.protocol.tcp.Command.CLIENT_GOODBYE_RESPONSE; +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.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcp2Client; +import org.apache.eventmesh.runtime.util.Utils; public class GoodbyeTask extends AbstractTask { @@ -50,7 +51,7 @@ public void run() { msg.setHeader(new Header(CLIENT_GOODBYE_RESPONSE, OPStatus.FAIL.getCode(), e.getStackTrace().toString(), pkg .getHeader().getSeq())); } finally { - EventMeshTCPServer.scheduler.submit(new Runnable() { + this.eventMeshTCPServer.getScheduler().submit(new Runnable() { @Override public void run() { Utils.writeAndFlush(msg, startTime, taskExecuteTime, session.getContext(), session); @@ -58,6 +59,6 @@ public void run() { }); //session.write2Client(msg); } - EventMeshTcp2Client.closeSessionIfTimeout(session, eventMeshTCPServer.getClientSessionGroupMapping()); + EventMeshTcp2Client.closeSessionIfTimeout(this.eventMeshTCPServer,session, eventMeshTCPServer.getClientSessionGroupMapping()); } } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/HeartBeatTask.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/HeartBeatTask.java similarity index 80% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/HeartBeatTask.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/HeartBeatTask.java index d939b62a26..eac1354cbe 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/HeartBeatTask.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/HeartBeatTask.java @@ -15,16 +15,17 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.task; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.task; + +import static org.apache.eventmesh.common.protocol.tcp.Command.HEARTBEAT_RESPONSE; -import com.webank.eventmesh.runtime.util.Utils; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; import io.netty.channel.ChannelHandlerContext; -import static com.webank.eventmesh.common.protocol.tcp.Command.HEARTBEAT_RESPONSE; +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.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.util.Utils; public class HeartBeatTask extends AbstractTask { @@ -41,11 +42,11 @@ public void run() { session.notifyHeartbeat(startTime); } res.setHeader(new Header(HEARTBEAT_RESPONSE, OPStatus.SUCCESS.getCode(), OPStatus.SUCCESS.getDesc(), pkg.getHeader().getSeq())); - }catch (Exception e){ + } catch (Exception e) { logger.error("HeartBeatTask failed|user={}|errMsg={}", session.getClient(), e); res.setHeader(new Header(HEARTBEAT_RESPONSE, OPStatus.FAIL.getCode(), "exception while " + "heartbeating", pkg.getHeader().getSeq())); - }finally { + } finally { Utils.writeAndFlush(res, startTime, taskExecuteTime, session.getContext(), session); } } diff --git a/eventmesh-runtime/src/main/java/com/webank/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 similarity index 84% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/HelloTask.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/HelloTask.java index 0001a79f91..53b97ec66e 100644 --- a/eventmesh-runtime/src/main/java/com/webank/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 @@ -15,26 +15,27 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.task; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.task; + +import static org.apache.eventmesh.common.protocol.tcp.Command.HELLO_RESPONSE; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import com.webank.eventmesh.runtime.util.Utils; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.runtime.common.ServiceState; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; 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.Header; +import org.apache.eventmesh.common.protocol.tcp.OPStatus; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; +import org.apache.eventmesh.runtime.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static com.webank.eventmesh.common.protocol.tcp.Command.HELLO_RESPONSE; - public class HelloTask extends AbstractTask { private final Logger messageLogger = LoggerFactory.getLogger("message"); @@ -50,7 +51,7 @@ public void run() { Session session = null; UserAgent user = (UserAgent) pkg.getBody(); try { - if(eventMeshTCPServer.getEventMeshServer().getServiceState() != ServiceState.RUNNING){ + if (eventMeshTCPServer.getEventMeshServer().getServiceState() != ServiceState.RUNNING) { logger.error("server state is not running:{}", eventMeshTCPServer.getEventMeshServer().getServiceState()); throw new Exception("server state is not running, maybe deploying..."); } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/ListenTask.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/ListenTask.java similarity index 84% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/ListenTask.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/ListenTask.java index a7a5c9dd44..4ce653a403 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/ListenTask.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/ListenTask.java @@ -15,15 +15,16 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.task; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.task; + +import static org.apache.eventmesh.common.protocol.tcp.Command.LISTEN_RESPONSE; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; import io.netty.channel.ChannelHandlerContext; -import static com.webank.eventmesh.common.protocol.tcp.Command.LISTEN_RESPONSE; +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.boot.EventMeshTCPServer; public class ListenTask extends AbstractTask { @@ -44,7 +45,7 @@ public void run() { logger.error("ListenTask failed|user={}|errMsg={}", session.getClient(), e); Integer status = OPStatus.FAIL.getCode(); header = new Header(LISTEN_RESPONSE, status, e.toString(), pkg.getHeader().getSeq()); - }finally { + } finally { // res.setHeader(header); // writeAndFlush(res, startTime, session.getContext(), session); //session.write2Client(res); diff --git a/eventmesh-runtime/src/main/java/com/webank/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 similarity index 85% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/MessageAckTask.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageAckTask.java index 9bfe00615a..a8605e92f6 100644 --- a/eventmesh-runtime/src/main/java/com/webank/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 @@ -15,13 +15,14 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.task; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.task; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.push.ClientAckContext; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.push.ClientAckContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,7 +45,7 @@ public void run() { return; } ClientAckContext clientAckContext = session.getPusher().getPushContext().getUnAckMsg().get(seq); - if(clientAckContext != null) { + if (clientAckContext != null) { session.ackMsg(seq); session.getClientGroupWrapper().get().getDownstreamMap().remove(seq); } diff --git a/eventmesh-runtime/src/main/java/com/webank/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 similarity index 88% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/MessageTransferTask.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageTransferTask.java index 71c147a042..c903742cdd 100644 --- a/eventmesh-runtime/src/main/java/com/webank/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 @@ -15,34 +15,34 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.task; - -import com.webank.eventmesh.runtime.constants.DeFiBusConstant; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.send.EventMeshTcpSendResult; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.send.EventMeshTcpSendStatus; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.util.Utils; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.task; + +import static org.apache.eventmesh.common.protocol.tcp.Command.RESPONSE_TO_SERVER; + +import java.util.concurrent.TimeUnit; + 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 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.OPStatus; +import org.apache.eventmesh.common.protocol.tcp.Package; +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.util.EventMeshUtil; +import org.apache.eventmesh.runtime.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.TimeUnit; - -import static com.webank.eventmesh.common.protocol.tcp.Command.RESPONSE_TO_SERVER; - public class MessageTransferTask extends AbstractTask { private final Logger messageLogger = LoggerFactory.getLogger("message"); @@ -67,7 +67,7 @@ public void run() { throw new Exception("eventMeshMessage is null"); } - if (!cmd.equals(RESPONSE_TO_SERVER) && !eventMeshTCPServer.rateLimiter.tryAcquire(TRY_PERMIT_TIME_OUT, TimeUnit.MILLISECONDS)) { + if (!cmd.equals(RESPONSE_TO_SERVER) && !eventMeshTCPServer.getRateLimiter().tryAcquire(TRY_PERMIT_TIME_OUT, TimeUnit.MILLISECONDS)) { msg.setHeader(new Header(replyCmd, OPStatus.FAIL.getCode(), "Tps overload, global flow control", pkg.getHeader().getSeq())); ctx.writeAndFlush(msg).addListener( new ChannelFutureListener() { @@ -77,7 +77,7 @@ public void operationComplete(ChannelFuture future) throws Exception { } } ); - logger.warn("======Tps overload, global flow control, rate:{}! PLEASE CHECK!========", eventMeshTCPServer.rateLimiter.getRate()); + logger.warn("======Tps overload, global flow control, rate:{}! PLEASE CHECK!========", eventMeshTCPServer.getRateLimiter().getRate()); return; } @@ -85,7 +85,7 @@ public void operationComplete(ChannelFuture future) throws Exception { long sendTime = System.currentTimeMillis(); addTimestamp(eventMeshMessage, cmd, sendTime); if (cmd.equals(Command.REQUEST_TO_SERVER)) { - eventMeshMessage.getProperties().put(DeFiBusConstant.PROPERTY_MESSAGE_REPLY_TO, session.getClientGroupWrapper() + eventMeshMessage.getProperties().put(EventMeshConstants.PROPERTY_MESSAGE_REPLY_TO, session.getClientGroupWrapper() .get().getMqProducerWrapper().getMeshMQProducer().buildMQClientId()); } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/SubscribeTask.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/SubscribeTask.java similarity index 84% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/SubscribeTask.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/SubscribeTask.java index 9e0604fc62..e26c66744d 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/SubscribeTask.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/SubscribeTask.java @@ -15,23 +15,24 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.task; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.task; + +import java.util.ArrayList; +import java.util.List; -import com.webank.eventmesh.runtime.util.EventMeshUtil; -import com.webank.eventmesh.runtime.util.Utils; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.Subscription; 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; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.Subscription; +import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.apache.eventmesh.runtime.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; - public class SubscribeTask extends AbstractTask { private final Logger messageLogger = LoggerFactory.getLogger("message"); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/UnSubscribeTask.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/UnSubscribeTask.java similarity index 86% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/UnSubscribeTask.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/UnSubscribeTask.java index fd19b662d8..3a338edcd6 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/core/protocol/tcp/client/task/UnSubscribeTask.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/UnSubscribeTask.java @@ -15,22 +15,23 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.core.protocol.tcp.client.task; +package org.apache.eventmesh.runtime.core.protocol.tcp.client.task; + +import java.util.ArrayList; +import java.util.List; -import com.webank.eventmesh.runtime.util.Utils; -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; import io.netty.channel.ChannelHandlerContext; + import org.apache.commons.collections4.MapUtils; +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.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; - public class UnSubscribeTask extends AbstractTask { private final Logger messageLogger = LoggerFactory.getLogger("message"); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/BytesMessageImpl.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/BytesMessageImpl.java similarity index 98% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/BytesMessageImpl.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/BytesMessageImpl.java index ca82dd6016..a91c9a3381 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/BytesMessageImpl.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/BytesMessageImpl.java @@ -14,7 +14,7 @@ // * See the License for the specific language governing permissions and // * limitations under the License. // */ -//package com.webank.eventmesh.runtime.domain; +//package org.apache.eventmesh.runtime.domain; // //import io.openmessaging.BytesMessage; //import io.openmessaging.KeyValue; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/ConsumeRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/ConsumeRequest.java similarity index 100% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/ConsumeRequest.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/ConsumeRequest.java diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/NonStandardKeys.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/NonStandardKeys.java similarity index 97% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/NonStandardKeys.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/NonStandardKeys.java index 745ec5cb15..779b3dccef 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/NonStandardKeys.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/NonStandardKeys.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.runtime.domain; +package org.apache.eventmesh.runtime.domain; public interface NonStandardKeys { String CONSUMER_GROUP = "rmq.consumer.group"; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/RocketMQConstants.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/RocketMQConstants.java similarity index 95% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/RocketMQConstants.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/RocketMQConstants.java index d31b5875cc..a8f08533df 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/RocketMQConstants.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/RocketMQConstants.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.webank.eventmesh.runtime.domain; +package org.apache.eventmesh.runtime.domain; public interface RocketMQConstants { diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/SendResultImpl.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/SendResultImpl.java similarity index 96% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/SendResultImpl.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/SendResultImpl.java index 9f31d0725f..3a8d12f999 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/domain/SendResultImpl.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/domain/SendResultImpl.java @@ -14,7 +14,7 @@ // * See the License for the specific language governing permissions and // * limitations under the License. // */ -//package com.webank.eventmesh.runtime.domain; +//package org.apache.eventmesh.runtime.domain; // //import io.openmessaging.KeyValue; //import io.openmessaging.producer.SendResult; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/MonitorMetricConstants.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/MonitorMetricConstants.java similarity index 97% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/MonitorMetricConstants.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/MonitorMetricConstants.java index 22ec426a28..60a2360ca1 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/MonitorMetricConstants.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/MonitorMetricConstants.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.metrics; +package org.apache.eventmesh.runtime.metrics; public class MonitorMetricConstants { public static final String EVENTMESH_MONITOR_FORMAT_COMMON = "{\"protocol\":\"%s\",\"s\":\"%s\",\"t\":\"%s\"}"; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/GroupMetrics.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/GroupMetrics.java similarity index 91% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/GroupMetrics.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/GroupMetrics.java index ebe13821b4..75f3d5d939 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/GroupMetrics.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/GroupMetrics.java @@ -15,11 +15,12 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.metrics.http; +package org.apache.eventmesh.runtime.metrics.http; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; import com.codahale.metrics.MetricRegistry; +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; + public class GroupMetrics { private EventMeshHTTPServer eventMeshHTTPServer; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/HTTPMetricsServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/HTTPMetricsServer.java similarity index 98% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/HTTPMetricsServer.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/HTTPMetricsServer.java index c66e06e526..3e333a0446 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/HTTPMetricsServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/HTTPMetricsServer.java @@ -15,12 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.metrics.http; - -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.codahale.metrics.MetricRegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.runtime.metrics.http; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -28,6 +23,12 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import com.codahale.metrics.MetricRegistry; + +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class HTTPMetricsServer { private EventMeshHTTPServer eventMeshHTTPServer; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/HealthMetrics.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/HealthMetrics.java similarity index 91% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/HealthMetrics.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/HealthMetrics.java index c40fa82286..6e59fb6369 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/HealthMetrics.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/HealthMetrics.java @@ -15,10 +15,11 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.metrics.http; +package org.apache.eventmesh.runtime.metrics.http; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; import com.codahale.metrics.MetricRegistry; + +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/SummaryMetrics.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/SummaryMetrics.java similarity index 99% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/SummaryMetrics.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/SummaryMetrics.java index f1e25e53f5..01ef0439cd 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/SummaryMetrics.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/SummaryMetrics.java @@ -15,18 +15,19 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.metrics.http; - -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.codahale.metrics.MetricRegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.runtime.metrics.http; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.concurrent.atomic.AtomicLong; +import com.codahale.metrics.MetricRegistry; + +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class SummaryMetrics { public Logger logger = LoggerFactory.getLogger("httpMonitor"); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/TcpSummaryMetrics.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/TcpSummaryMetrics.java similarity index 99% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/TcpSummaryMetrics.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/TcpSummaryMetrics.java index 73a3cdd4bf..4c69c67729 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/TcpSummaryMetrics.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/TcpSummaryMetrics.java @@ -15,18 +15,19 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.metrics.http; - -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; -import com.codahale.metrics.MetricRegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.runtime.metrics.http; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.concurrent.atomic.AtomicLong; +import com.codahale.metrics.MetricRegistry; + +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class TcpSummaryMetrics { public Logger logger = LoggerFactory.getLogger("httpMonitor"); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/TopicMetrics.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/TopicMetrics.java similarity index 91% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/TopicMetrics.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/TopicMetrics.java index 2d89414436..6a0afabdc9 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/http/TopicMetrics.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/http/TopicMetrics.java @@ -15,11 +15,12 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.metrics.http; +package org.apache.eventmesh.runtime.metrics.http; -import com.webank.eventmesh.runtime.boot.EventMeshHTTPServer; import com.codahale.metrics.MetricRegistry; +import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; + public class TopicMetrics { private EventMeshHTTPServer eventMeshHTTPServer; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/tcp/EventMeshTcpMonitor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/tcp/EventMeshTcpMonitor.java similarity index 93% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/tcp/EventMeshTcpMonitor.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/tcp/EventMeshTcpMonitor.java index 84528b5ba9..64775275a0 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/metrics/tcp/EventMeshTcpMonitor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/tcp/EventMeshTcpMonitor.java @@ -15,15 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.metrics.tcp; - -import com.webank.eventmesh.runtime.boot.EventMeshTCPServer; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcpConnectionHandler; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.metrics.MonitorMetricConstants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.runtime.metrics.tcp; import java.net.InetSocketAddress; import java.util.HashSet; @@ -35,6 +27,14 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcpConnectionHandler; +import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.Session; +import org.apache.eventmesh.runtime.metrics.MonitorMetricConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class EventMeshTcpMonitor { private EventMeshTCPServer eventMeshTCPServer; @@ -80,7 +80,7 @@ public void init() throws Exception { } public void start() throws Exception { - monitorTpsTask = eventMeshTCPServer.scheduler.scheduleAtFixedRate((new Runnable() { + monitorTpsTask = eventMeshTCPServer.getScheduler().scheduleAtFixedRate((new Runnable() { @Override public void run() { int msgNum = client2eventMeshMsgNum.intValue(); @@ -132,7 +132,7 @@ public void run() { } }), delay, period, TimeUnit.MILLISECONDS); - monitorThreadPoolTask = eventMeshTCPServer.scheduler.scheduleAtFixedRate(new Runnable() { + monitorThreadPoolTask = eventMeshTCPServer.getScheduler().scheduleAtFixedRate(new Runnable() { @Override public void run() { // ThreadPoolHelper.printThreadPoolState(); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/patch/EventMeshConsumeConcurrentlyContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/patch/EventMeshConsumeConcurrentlyContext.java similarity index 97% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/patch/EventMeshConsumeConcurrentlyContext.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/patch/EventMeshConsumeConcurrentlyContext.java index 3b17f097fb..80c90bf4a5 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/patch/EventMeshConsumeConcurrentlyContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/patch/EventMeshConsumeConcurrentlyContext.java @@ -15,7 +15,7 @@ // * limitations under the License. // */ // -//package com.webank.eventmesh.runtime.patch; +//package org.apache.eventmesh.runtime.patch; // //import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; //import org.apache.rocketmq.client.impl.consumer.ProcessQueue; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/patch/EventMeshConsumeConcurrentlyStatus.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/patch/EventMeshConsumeConcurrentlyStatus.java similarity index 96% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/patch/EventMeshConsumeConcurrentlyStatus.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/patch/EventMeshConsumeConcurrentlyStatus.java index f3d0756893..008f459f18 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/patch/EventMeshConsumeConcurrentlyStatus.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/patch/EventMeshConsumeConcurrentlyStatus.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.patch; +package org.apache.eventmesh.runtime.patch; public enum EventMeshConsumeConcurrentlyStatus { /** diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/patch/EventMeshMessageListenerConcurrently.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/patch/EventMeshMessageListenerConcurrently.java similarity index 98% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/patch/EventMeshMessageListenerConcurrently.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/patch/EventMeshMessageListenerConcurrently.java index d89d8ad143..202c0e19d1 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/patch/EventMeshMessageListenerConcurrently.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/patch/EventMeshMessageListenerConcurrently.java @@ -15,7 +15,7 @@ // * limitations under the License. // */ // -//package com.webank.eventmesh.runtime.patch; +//package org.apache.eventmesh.runtime.patch; // //import org.apache.commons.collections4.CollectionUtils; //import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/EventMeshThreadFactoryImpl.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/EventMeshThreadFactoryImpl.java similarity index 92% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/EventMeshThreadFactoryImpl.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/EventMeshThreadFactoryImpl.java index f63d5e039d..cf83904115 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/EventMeshThreadFactoryImpl.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/EventMeshThreadFactoryImpl.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.util; +package org.apache.eventmesh.runtime.util; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicLong; @@ -40,7 +40,7 @@ public String getThreadNamePrefix() { @Override public Thread newThread(Runnable r) { - Thread t = new Thread(r, threadNamePrefix +'-'+ this.threadIndex.incrementAndGet()); + Thread t = new Thread(r, threadNamePrefix + '-' + this.threadIndex.incrementAndGet()); if (isDaemonSpecified != null) { t.setDaemon(isDaemonSpecified); } diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/EventMeshUtil.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/EventMeshUtil.java similarity index 95% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/EventMeshUtil.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/EventMeshUtil.java index 560e3c2d1e..3814fb7de5 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/EventMeshUtil.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/EventMeshUtil.java @@ -15,36 +15,43 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.util; +package org.apache.eventmesh.runtime.util; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.constants.EventMeshVersion; -import com.webank.eventmesh.common.ThreadUtil; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; +import static org.apache.eventmesh.runtime.util.OMSUtil.isOMSHeader; + +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.TimeZone; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; + import io.openmessaging.api.Message; + import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.ThreadUtil; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.constants.EventMeshVersion; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.net.Inet6Address; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.nio.charset.StandardCharsets; -import java.util.*; - -import static com.webank.eventmesh.runtime.util.OMSUtil.isOMSHeader; - public class EventMeshUtil { public static Logger logger = LoggerFactory.getLogger(EventMeshUtil.class); @@ -91,6 +98,7 @@ public static String buildBroadcastClientConsumerGroup(String systemId, String d public static String buildPersistentClientConsumerGroup(String systemId, String dcn) { return EventMeshConstants.CONSUMER_GROUP_NAME_PREFIX + systemId + "-" + dcn; } + public static String buildClientGroup(String systemId, String dcn) { return systemId + "-" + dcn; } @@ -290,9 +298,9 @@ public static EventMeshMessage encodeMessage(Message omsMessage) throws Exceptio if (sysHeaders.containsKey("START_TIME")) { long deliverTime; - if (StringUtils.isBlank(sysHeaders.getProperty("START_TIME"))){ + if (StringUtils.isBlank(sysHeaders.getProperty("START_TIME"))) { deliverTime = 0; - }else { + } else { deliverTime = Long.parseLong(sysHeaders.getProperty("START_TIME")); } @@ -406,8 +414,8 @@ private static void getIpResult(ArrayList ipv4Result, ArrayList } } - public static String buildUserAgentClientId(UserAgent client){ - if(client == null){ + public static String buildUserAgentClientId(UserAgent client) { + if (client == null) { return null; } StringBuilder sb = new StringBuilder(); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/HttpTinyClient.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/HttpTinyClient.java similarity index 93% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/HttpTinyClient.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/HttpTinyClient.java index 121e59e36c..f3a930ca0b 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/HttpTinyClient.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/HttpTinyClient.java @@ -15,9 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.util; - -import com.webank.eventmesh.runtime.constants.EventMeshConstants; +package org.apache.eventmesh.runtime.util; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -27,10 +25,12 @@ import java.util.Iterator; import java.util.List; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; + public class HttpTinyClient { static public HttpResult httpGet(String url, List headers, List paramValues, - String encoding, long readTimeoutMs) throws IOException { + String encoding, long readTimeoutMs) throws IOException { String encodedContent = encodingParams(paramValues, encoding); url += (null == encodedContent) ? "" : ("?" + encodedContent); @@ -60,7 +60,7 @@ static public HttpResult httpGet(String url, List headers, List } static private String encodingParams(List paramValues, String encoding) - throws UnsupportedEncodingException { + throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); if (null == paramValues) { return null; @@ -93,7 +93,7 @@ static private void setHeaders(HttpURLConnection conn, List headers, Str * @return the http response of given http post request */ static public HttpResult httpPost(String url, List headers, List paramValues, - String encoding, long readTimeoutMs) throws IOException { + String encoding, long readTimeoutMs) throws IOException { String encodedContent = encodingParams(paramValues, encoding); HttpURLConnection conn = null; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/IOTinyUtils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/IOTinyUtils.java similarity index 91% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/IOTinyUtils.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/IOTinyUtils.java index e4d4867d8e..7ce4d154aa 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/IOTinyUtils.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/IOTinyUtils.java @@ -15,20 +15,30 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.util; - -import com.webank.eventmesh.runtime.constants.EventMeshConstants; - -import java.io.*; +package org.apache.eventmesh.runtime.util; + +import java.io.BufferedReader; +import java.io.CharArrayWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.List; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; + public class IOTinyUtils { static public String toString(InputStream input, String encoding) throws IOException { return (null == encoding) ? toString(new InputStreamReader(input, EventMeshConstants.DEFAULT_CHARSET)) : toString(new InputStreamReader( - input, encoding)); + input, encoding)); } static public String toString(Reader reader) throws IOException { diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/OMSUtil.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/OMSUtil.java similarity index 61% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/OMSUtil.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/OMSUtil.java index 82927e362b..32e310f84e 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/OMSUtil.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/OMSUtil.java @@ -1,5 +1,23 @@ +/* + * 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 com.webank.eventmesh.runtime.util; +package org.apache.eventmesh.runtime.util; import java.lang.reflect.Field; import java.util.HashMap; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/RemotingHelper.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/RemotingHelper.java similarity index 86% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/RemotingHelper.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/RemotingHelper.java index 942b2ecb11..0266a924dd 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/RemotingHelper.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/RemotingHelper.java @@ -1,8 +1,28 @@ -package com.webank.eventmesh.runtime.util; +/* + * 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 io.netty.channel.Channel; import java.net.InetSocketAddress; import java.net.SocketAddress; + +import io.netty.channel.Channel; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -12,7 +32,7 @@ public class RemotingHelper { public static Logger logger = LoggerFactory.getLogger(RemotingHelper.class); public static String exceptionSimpleDesc(final Throwable e) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (e != null) { sb.append(e.toString()); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/ServerGlobal.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/ServerGlobal.java similarity index 96% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/ServerGlobal.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/ServerGlobal.java index 28541680ee..9ef4422946 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/ServerGlobal.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/ServerGlobal.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.util; +package org.apache.eventmesh.runtime.util; import java.util.concurrent.atomic.AtomicLong; diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/Utils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/Utils.java similarity index 95% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/Utils.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/Utils.java index c46253fa8e..f3596e6a74 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/Utils.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/Utils.java @@ -15,21 +15,23 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.util; - -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.Session; -import com.webank.eventmesh.runtime.core.protocol.tcp.client.session.SessionState; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; +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.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Map; public class Utils { private final static Logger logger = LoggerFactory.getLogger(Utils.class); diff --git a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/ValueComparator.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/ValueComparator.java similarity index 96% rename from eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/ValueComparator.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/ValueComparator.java index 6e429ccf40..2eb24e57fd 100644 --- a/eventmesh-runtime/src/main/java/com/webank/eventmesh/runtime/util/ValueComparator.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/ValueComparator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.runtime.util; +package org.apache.eventmesh.runtime.util; import java.util.Comparator; import java.util.Map; diff --git a/eventmesh-runtime/src/test/java/client/EventMeshClient.java b/eventmesh-runtime/src/test/java/client/EventMeshClient.java index 9b6c890d81..ce4a13ed4a 100644 --- a/eventmesh-runtime/src/test/java/client/EventMeshClient.java +++ b/eventmesh-runtime/src/test/java/client/EventMeshClient.java @@ -17,8 +17,10 @@ package client; +import org.apache.eventmesh.common.protocol.tcp.Package; + import client.hook.ReceiveMsgHook; -import com.webank.eventmesh.common.protocol.tcp.Package; + public interface EventMeshClient { Package rr(Package msg, long timeout) throws Exception; diff --git a/eventmesh-runtime/src/test/java/client/PubClient.java b/eventmesh-runtime/src/test/java/client/PubClient.java index 90c8c57ef2..452279d400 100644 --- a/eventmesh-runtime/src/test/java/client/PubClient.java +++ b/eventmesh-runtime/src/test/java/client/PubClient.java @@ -17,9 +17,10 @@ package client; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; + import client.hook.ReceiveMsgHook; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; public interface PubClient { diff --git a/eventmesh-runtime/src/test/java/client/SubClient.java b/eventmesh-runtime/src/test/java/client/SubClient.java index a15ab114f2..dff635ac0d 100644 --- a/eventmesh-runtime/src/test/java/client/SubClient.java +++ b/eventmesh-runtime/src/test/java/client/SubClient.java @@ -17,9 +17,10 @@ package client; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; + import client.hook.ReceiveMsgHook; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; public interface SubClient { diff --git a/eventmesh-runtime/src/test/java/client/common/ClientGlobal.java b/eventmesh-runtime/src/test/java/client/common/ClientGlobal.java index 91bf50773f..d4ce76abea 100644 --- a/eventmesh-runtime/src/test/java/client/common/ClientGlobal.java +++ b/eventmesh-runtime/src/test/java/client/common/ClientGlobal.java @@ -17,15 +17,16 @@ package client.common; +import java.util.TimeZone; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.TimeZone; - public class ClientGlobal { diff --git a/eventmesh-runtime/src/test/java/client/common/Codec.java b/eventmesh-runtime/src/test/java/client/common/Codec.java index ec9026a282..82ffcb0aec 100644 --- a/eventmesh-runtime/src/test/java/client/common/Codec.java +++ b/eventmesh-runtime/src/test/java/client/common/Codec.java @@ -17,25 +17,26 @@ package client.common; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.RedirectInfo; -import com.webank.eventmesh.common.protocol.tcp.Subscription; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; +import java.nio.charset.Charset; +import java.util.Arrays; +import java.util.List; + import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.ReplayingDecoder; + +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.apache.eventmesh.runtime.constants.EventMeshConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.List; - public class Codec { private final static Logger logger = LoggerFactory.getLogger(Codec.class); diff --git a/eventmesh-runtime/src/test/java/client/common/MessageUtils.java b/eventmesh-runtime/src/test/java/client/common/MessageUtils.java index 9b10574ab4..0eb313ed3e 100644 --- a/eventmesh-runtime/src/test/java/client/common/MessageUtils.java +++ b/eventmesh-runtime/src/test/java/client/common/MessageUtils.java @@ -17,17 +17,17 @@ package client.common; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.Subscription; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; - import java.util.ArrayList; import java.util.List; import java.util.concurrent.ThreadLocalRandom; +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; + public class MessageUtils { public static int seqLength = 10; diff --git a/eventmesh-runtime/src/test/java/client/common/RequestContext.java b/eventmesh-runtime/src/test/java/client/common/RequestContext.java index 149b4b4e0d..2319403490 100644 --- a/eventmesh-runtime/src/test/java/client/common/RequestContext.java +++ b/eventmesh-runtime/src/test/java/client/common/RequestContext.java @@ -17,12 +17,12 @@ package client.common; -import com.webank.eventmesh.common.protocol.tcp.Package; +import java.util.concurrent.CountDownLatch; + +import org.apache.eventmesh.common.protocol.tcp.Package; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.CountDownLatch; - public class RequestContext { private static Logger logger = LoggerFactory.getLogger(RequestContext.class); diff --git a/eventmesh-runtime/src/test/java/client/common/Server.java b/eventmesh-runtime/src/test/java/client/common/Server.java index 909041c822..85402890fa 100644 --- a/eventmesh-runtime/src/test/java/client/common/Server.java +++ b/eventmesh-runtime/src/test/java/client/common/Server.java @@ -17,8 +17,8 @@ package client.common; -import com.webank.eventmesh.runtime.boot.EventMeshServer; -import com.webank.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; +import org.apache.eventmesh.runtime.boot.EventMeshServer; +import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; public class Server { diff --git a/eventmesh-runtime/src/test/java/client/common/TCPClient.java b/eventmesh-runtime/src/test/java/client/common/TCPClient.java index 4a7d30c13f..c0068de8eb 100644 --- a/eventmesh-runtime/src/test/java/client/common/TCPClient.java +++ b/eventmesh-runtime/src/test/java/client/common/TCPClient.java @@ -17,7 +17,17 @@ package client.common; -import com.webank.eventmesh.common.protocol.tcp.Package; +import java.io.Closeable; +import java.net.InetSocketAddress; +import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicInteger; + import io.netty.bootstrap.Bootstrap; import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.AdaptiveRecvByteBufAllocator; @@ -32,20 +42,11 @@ import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; + +import org.apache.eventmesh.common.protocol.tcp.Package; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.Closeable; -import java.net.InetSocketAddress; -import java.util.Random; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicInteger; - /** * 一个Client连一个ACCESS diff --git a/eventmesh-runtime/src/test/java/client/common/UserAgentUtils.java b/eventmesh-runtime/src/test/java/client/common/UserAgentUtils.java index 7ba72d6863..eff23f1a9c 100644 --- a/eventmesh-runtime/src/test/java/client/common/UserAgentUtils.java +++ b/eventmesh-runtime/src/test/java/client/common/UserAgentUtils.java @@ -17,13 +17,11 @@ package client.common; -import com.webank.eventmesh.runtime.constants.EventMeshConstants; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -//import org.apache.rocketmq.common.UtilAll; -//import org.apache.rocketmq.remoting.common.RemotingUtil; - import java.util.concurrent.ThreadLocalRandom; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; + public class UserAgentUtils { public static UserAgent createPubUserAgent() { UserAgent userAgent = new UserAgent(); diff --git a/eventmesh-runtime/src/test/java/client/hook/ReceiveMsgHook.java b/eventmesh-runtime/src/test/java/client/hook/ReceiveMsgHook.java index bd6622c88b..6aca270f46 100644 --- a/eventmesh-runtime/src/test/java/client/hook/ReceiveMsgHook.java +++ b/eventmesh-runtime/src/test/java/client/hook/ReceiveMsgHook.java @@ -17,8 +17,10 @@ package client.hook; -import com.webank.eventmesh.common.protocol.tcp.Package; import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.common.protocol.tcp.Package; + /** * 业务回调钩子, 这是针对所有类型的消息都会进行的回调 */ diff --git a/eventmesh-runtime/src/test/java/client/impl/EventMeshClientImpl.java b/eventmesh-runtime/src/test/java/client/impl/EventMeshClientImpl.java index a0f361d0e8..5f58c1e54f 100644 --- a/eventmesh-runtime/src/test/java/client/impl/EventMeshClientImpl.java +++ b/eventmesh-runtime/src/test/java/client/impl/EventMeshClientImpl.java @@ -17,13 +17,14 @@ package client.impl; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; + import client.EventMeshClient; import client.PubClient; import client.SubClient; import client.common.UserAgentUtils; import client.hook.ReceiveMsgHook; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; public class EventMeshClientImpl implements EventMeshClient { protected UserAgent agent; diff --git a/eventmesh-runtime/src/test/java/client/impl/PubClientImpl.java b/eventmesh-runtime/src/test/java/client/impl/PubClientImpl.java index 2cb8f3238b..ee01069dc1 100644 --- a/eventmesh-runtime/src/test/java/client/impl/PubClientImpl.java +++ b/eventmesh-runtime/src/test/java/client/impl/PubClientImpl.java @@ -17,25 +17,27 @@ package client.impl; -import client.PubClient; -import client.common.ClientConstants; -import client.common.MessageUtils; -import client.common.RequestContext; -import client.common.TCPClient; -import client.hook.ReceiveMsgHook; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; +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.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.OPStatus; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.junit.Assert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; +import client.PubClient; +import client.common.ClientConstants; +import client.common.MessageUtils; +import client.common.RequestContext; +import client.common.TCPClient; +import client.hook.ReceiveMsgHook; public class PubClientImpl extends TCPClient implements PubClient { diff --git a/eventmesh-runtime/src/test/java/client/impl/SubClientImpl.java b/eventmesh-runtime/src/test/java/client/impl/SubClientImpl.java index 0f578567b1..3a61b48683 100644 --- a/eventmesh-runtime/src/test/java/client/impl/SubClientImpl.java +++ b/eventmesh-runtime/src/test/java/client/impl/SubClientImpl.java @@ -17,28 +17,30 @@ package client.impl; -import client.SubClient; -import client.common.ClientConstants; -import client.common.MessageUtils; -import client.common.RequestContext; -import client.common.TCPClient; -import client.hook.ReceiveMsgHook; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.OPStatus; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; +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.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.OPStatus; +import org.apache.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.junit.Assert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; +import client.SubClient; +import client.common.ClientConstants; +import client.common.MessageUtils; +import client.common.RequestContext; +import client.common.TCPClient; +import client.hook.ReceiveMsgHook; public class SubClientImpl extends TCPClient implements SubClient { diff --git a/eventmesh-runtime/src/test/java/demo/AsyncPubClient.java b/eventmesh-runtime/src/test/java/demo/AsyncPubClient.java index 115537c4ec..911105a426 100644 --- a/eventmesh-runtime/src/test/java/demo/AsyncPubClient.java +++ b/eventmesh-runtime/src/test/java/demo/AsyncPubClient.java @@ -17,14 +17,16 @@ package demo; +import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.common.ThreadUtil; +import org.apache.eventmesh.common.protocol.tcp.Package; + import client.common.ClientConstants; import client.common.MessageUtils; import client.common.UserAgentUtils; import client.hook.ReceiveMsgHook; import client.impl.PubClientImpl; -import com.webank.eventmesh.common.ThreadUtil; -import com.webank.eventmesh.common.protocol.tcp.Package; -import io.netty.channel.ChannelHandlerContext; public class AsyncPubClient { public static void main(String[] args) throws Exception { diff --git a/eventmesh-runtime/src/test/java/demo/AsyncSubClient.java b/eventmesh-runtime/src/test/java/demo/AsyncSubClient.java index a2f71550b8..eb55d0ec7a 100644 --- a/eventmesh-runtime/src/test/java/demo/AsyncSubClient.java +++ b/eventmesh-runtime/src/test/java/demo/AsyncSubClient.java @@ -17,13 +17,15 @@ package demo; +import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; +import org.apache.eventmesh.common.protocol.tcp.Package; + import client.common.ClientConstants; import client.common.MessageUtils; import client.hook.ReceiveMsgHook; import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Package; -import io.netty.channel.ChannelHandlerContext; public class AsyncSubClient { public static void main(String[] args) throws Exception { diff --git a/eventmesh-runtime/src/test/java/demo/BroadCastPubClient.java b/eventmesh-runtime/src/test/java/demo/BroadCastPubClient.java index e0e2841873..637898509f 100644 --- a/eventmesh-runtime/src/test/java/demo/BroadCastPubClient.java +++ b/eventmesh-runtime/src/test/java/demo/BroadCastPubClient.java @@ -17,11 +17,12 @@ package demo; +import org.apache.eventmesh.common.ThreadUtil; + import client.common.ClientConstants; import client.common.MessageUtils; import client.common.UserAgentUtils; import client.impl.PubClientImpl; -import com.webank.eventmesh.common.ThreadUtil; public class BroadCastPubClient { public static void main(String[] args) throws Exception { diff --git a/eventmesh-runtime/src/test/java/demo/BroadCastSubClient.java b/eventmesh-runtime/src/test/java/demo/BroadCastSubClient.java index dbecf4254b..f3f29f666a 100644 --- a/eventmesh-runtime/src/test/java/demo/BroadCastSubClient.java +++ b/eventmesh-runtime/src/test/java/demo/BroadCastSubClient.java @@ -17,14 +17,16 @@ package demo; +import io.netty.channel.ChannelHandlerContext; + +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 client.common.ClientConstants; import client.common.MessageUtils; import client.hook.ReceiveMsgHook; import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import io.netty.channel.ChannelHandlerContext; public class BroadCastSubClient { public static void main(String[] args) throws Exception { diff --git a/eventmesh-runtime/src/test/java/demo/CCSubClient.java b/eventmesh-runtime/src/test/java/demo/CCSubClient.java index 6c1e21fef9..d415743cf3 100644 --- a/eventmesh-runtime/src/test/java/demo/CCSubClient.java +++ b/eventmesh-runtime/src/test/java/demo/CCSubClient.java @@ -17,13 +17,15 @@ package demo; +import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.Package; + import client.common.MessageUtils; import client.common.UserAgentUtils; import client.hook.ReceiveMsgHook; import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import io.netty.channel.ChannelHandlerContext; public class CCSubClient { diff --git a/eventmesh-runtime/src/test/java/demo/CClientDemo.java b/eventmesh-runtime/src/test/java/demo/CClientDemo.java index ebc2a5563f..590aa3fe2c 100644 --- a/eventmesh-runtime/src/test/java/demo/CClientDemo.java +++ b/eventmesh-runtime/src/test/java/demo/CClientDemo.java @@ -17,15 +17,17 @@ package demo; -import client.common.MessageUtils; -import client.hook.ReceiveMsgHook; -import client.impl.EventMeshClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.Package; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import client.common.MessageUtils; +import client.hook.ReceiveMsgHook; +import client.impl.EventMeshClientImpl; + /** * SIMPLE客户端使用样例 */ diff --git a/eventmesh-runtime/src/test/java/demo/SyncPubClient.java b/eventmesh-runtime/src/test/java/demo/SyncPubClient.java index ae87df0565..18a032fbc5 100644 --- a/eventmesh-runtime/src/test/java/demo/SyncPubClient.java +++ b/eventmesh-runtime/src/test/java/demo/SyncPubClient.java @@ -17,11 +17,12 @@ package demo; +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; +import org.apache.eventmesh.common.protocol.tcp.Package; + import client.common.MessageUtils; import client.common.UserAgentUtils; import client.impl.PubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Package; public class SyncPubClient { public static void main(String[] args) throws Exception { diff --git a/eventmesh-runtime/src/test/java/demo/SyncSubClient.java b/eventmesh-runtime/src/test/java/demo/SyncSubClient.java index 50a62adf8b..10e13c4ae8 100644 --- a/eventmesh-runtime/src/test/java/demo/SyncSubClient.java +++ b/eventmesh-runtime/src/test/java/demo/SyncSubClient.java @@ -17,13 +17,15 @@ package demo; +import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.Package; + import client.common.ClientConstants; import client.common.MessageUtils; import client.hook.ReceiveMsgHook; import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import io.netty.channel.ChannelHandlerContext; public class SyncSubClient { public static void main(String[] args) throws Exception { diff --git a/eventmesh-runtime/src/test/java/protocol/CmdAsync2ClientTest.java b/eventmesh-runtime/src/test/java/protocol/CmdAsync2ClientTest.java deleted file mode 100644 index 774f1325e0..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdAsync2ClientTest.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 protocol; - -import client.PubClient; -import client.common.Server; -import client.common.UserAgentUtils; -import client.hook.ReceiveMsgHook; -import client.impl.PubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import io.netty.channel.ChannelHandlerContext; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Cmd Test: Async Message To Client - */ -public class CmdAsync2ClientTest { - - public static Server server = new Server(); - public static PubClient client = new PubClientImpl("127.0.0.1", 10000, UserAgentUtils.createSubUserAgent()); - - @BeforeClass - public static void before_Cmd_AsyncMessage() throws Exception { - server.startAccessServer(); - client.init(); - } - - @Test - public void test_Cmd_AsyncMessage() throws Exception { - client.registerBusiHandler(new ReceiveMsgHook() { - @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - System.err.println("receive response from server:------------------" + msg.toString()); - if (msg.getHeader().getCommand() == Command.CLIENT_GOODBYE_RESPONSE) { - Assert.assertTrue("HEARTBEAT_RESPONSE", true); - } - } - }); - Package msg = new Package(); - client.publish(msg, 3000); -// Thread.sleep(10000); - } - - @AfterClass - public static void after_Cmd_AsyncMessage() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } -} diff --git a/eventmesh-runtime/src/test/java/protocol/CmdAsync2ServerTest.java b/eventmesh-runtime/src/test/java/protocol/CmdAsync2ServerTest.java deleted file mode 100644 index 7c3b1ae979..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdAsync2ServerTest.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 protocol; - -import client.PubClient; -import client.common.MessageUtils; -import client.common.Server; -import client.common.UserAgentUtils; -import client.impl.PubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -public class CmdAsync2ServerTest { - - public static Server server = new Server(); - public static PubClient client = new PubClientImpl("127.0.0.1", 10000, UserAgentUtils.createSubUserAgent()); - - @BeforeClass - public static void before_Cmd_AsyncMessage2Server() throws Exception { - server.startAccessServer(); - client.init(); - Thread.sleep(1000); - } - - @Test - public void test_Cmd_AsyncMessage2Server() throws Exception { - Package msg = MessageUtils.asyncMessage("FT0-e-80010000-01-1", 0); - Package replyMsg = client.publish(msg, 3000); - System.err.println("Reply Message-----------------------------------------" + replyMsg.toString()); - if (replyMsg.getHeader().getCommand() != Command.ASYNC_MESSAGE_TO_SERVER_ACK) { - Assert.assertTrue("ASYNC_MESSAGE_TO_SERVER_ACK FAIL", false); - } - } - - @AfterClass - public static void after_Cmd_AsyncMessage2Server() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } -} diff --git a/eventmesh-runtime/src/test/java/protocol/CmdBroadCast2ClientTest.java b/eventmesh-runtime/src/test/java/protocol/CmdBroadCast2ClientTest.java deleted file mode 100644 index ddd2afbcfb..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdBroadCast2ClientTest.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 protocol; - -import client.SubClient; -import client.common.Server; -import client.common.UserAgentUtils; -import client.hook.ReceiveMsgHook; -import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import io.netty.channel.ChannelHandlerContext; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Cmd Test: BroadCast To Client - */ -public class CmdBroadCast2ClientTest { - - public static Server server = new Server(); - public static SubClient client = new SubClientImpl("127.0.0.1", 10000, UserAgentUtils.createSubUserAgent()); - - @BeforeClass - public static void before_Cmd_broadcast() throws Exception { - server.startAccessServer(); - client.init(); - } - - @Test - public void test_Cmd_broadcast() throws Exception { - client.registerBusiHandler(new ReceiveMsgHook() { - @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - System.err.println("receive response from server:------------------" + msg.toString()); - if (msg.getHeader().getCommand() == Command.BROADCAST_MESSAGE_TO_CLIENT) { - Assert.assertTrue("HEARTBEAT_RESPONSE", true); - } - } - }); - Package msg = new Package(); -// client.publish(msg,3000); -// Thread.sleep(10000); - } - - @AfterClass - public static void after_Cmd_broadcast() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } - -} diff --git a/eventmesh-runtime/src/test/java/protocol/CmdBroadCast2ServerTest.java b/eventmesh-runtime/src/test/java/protocol/CmdBroadCast2ServerTest.java deleted file mode 100644 index 928a76fed0..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdBroadCast2ServerTest.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 protocol; - -import client.PubClient; -import client.common.MessageUtils; -import client.common.Server; -import client.common.UserAgentUtils; -import client.impl.PubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -public class CmdBroadCast2ServerTest { - - public static Server server = new Server(); - public static PubClient client = new PubClientImpl("127.0.0.1", 10000, UserAgentUtils.createSubUserAgent()); - - @BeforeClass - public static void before_Cmd_broadcast2Server() throws Exception { - server.startAccessServer(); - client.init(); - Thread.sleep(1000); - } - - @Test - public void test_Cmd_broadcast2Server() throws Exception { - Package msg = MessageUtils.broadcastMessage("FT0-e-80030000-01-3", 0); - Package replyMsg = client.broadcast(msg, 3000); - System.err.println("Reply Message-----------------------------------------" + replyMsg.toString()); - if (replyMsg.getHeader().getCommand() != Command.BROADCAST_MESSAGE_TO_SERVER_ACK) { - Assert.assertTrue("BROADCAST_MESSAGE_TO_SERVER_ACK FAIL", false); - } - } - - @AfterClass - public static void after_Cmd_broadcast2Server() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } - -} diff --git a/eventmesh-runtime/src/test/java/protocol/CmdClientGoodByTest.java b/eventmesh-runtime/src/test/java/protocol/CmdClientGoodByTest.java deleted file mode 100644 index b0a3d51de5..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdClientGoodByTest.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 protocol; - -import client.SubClient; -import client.common.Server; -import client.common.UserAgentUtils; -import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test Cmd: CLIENT_GOODBYE_REQUEST - */ -public class CmdClientGoodByTest { - public static Server server = new Server(); - public static SubClient client = new SubClientImpl("127.0.0.1", 10000, UserAgentUtils.createSubUserAgent()); - - @BeforeClass - public static void before_Cmd_client_goodbye() throws Exception { - server.startAccessServer(); - client.init(); - Thread.sleep(1000); - } - - @Test - public void test_Cmd_client_goodbye() throws Exception { - Package replyMsg = client.goodbye(); - System.err.println("Reply Message-----------------------------------------" + replyMsg.toString()); - if (replyMsg.getHeader().getCommand() != Command.CLIENT_GOODBYE_RESPONSE) { - Assert.assertTrue("CLIENT_GOODBYE_RESPONSE FAIL", false); - } - } - - @AfterClass - public static void after_Cmd_client_goodbye() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } -} diff --git a/eventmesh-runtime/src/test/java/protocol/CmdHeartbeatTest.java b/eventmesh-runtime/src/test/java/protocol/CmdHeartbeatTest.java deleted file mode 100644 index 978abbd159..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdHeartbeatTest.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 protocol; - -import client.PubClient; -import client.common.Server; -import client.common.UserAgentUtils; -import client.hook.ReceiveMsgHook; -import client.impl.PubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import io.netty.channel.ChannelHandlerContext; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Cmd Test : HeartBeat - */ -public class CmdHeartbeatTest { - public static Server server = new Server(); - public static PubClient client = new PubClientImpl("127.0.0.1", 10000, UserAgentUtils.createPubUserAgent()); - - @BeforeClass - public static void before_Cmd_hearbeat() throws Exception { - server.startAccessServer(); - client.init(); - Thread.sleep(1000); - } - - @Test - public void test_Cmd_heartbeat() throws Exception { - client.registerBusiHandler(new ReceiveMsgHook() { - @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - System.err.println("receive response from server:------------------" + msg.toString()); - if (msg.getHeader().getCommand() != Command.HEARTBEAT_RESPONSE) { - Assert.assertTrue("HEARTBEAT_RESPONSE", false); - } - } - }); - client.heartbeat(); - - Thread.sleep(10000); - } - - @AfterClass - public static void after_Cmd_heartbeat() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } -} diff --git a/eventmesh-runtime/src/test/java/protocol/CmdListenTest.java b/eventmesh-runtime/src/test/java/protocol/CmdListenTest.java deleted file mode 100644 index 300bb2b469..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdListenTest.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 protocol; - -import client.SubClient; -import client.common.Server; -import client.common.UserAgentUtils; -import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Cmd Test: LISTEN_REQUEST - */ -public class CmdListenTest { - public static Server server = new Server(); - public static SubClient client = new SubClientImpl("127.0.0.1", 10000, UserAgentUtils.createSubUserAgent()); - - @BeforeClass - public static void before_Cmd_listen() throws Exception { - server.startAccessServer(); - client.init(); - Thread.sleep(1000); - } - - @AfterClass - public static void after_Cmd_listen() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } - - @Test - public void test_Cmd_listen() throws Exception { - Package replyMsg = client.listen(); - System.err.println("Reply Message-----------------------------------------" + replyMsg.toString()); - if (replyMsg.getHeader().getCommand() != Command.LISTEN_RESPONSE) { - Assert.assertTrue("SUBSCRIBE_RESPONSE FAIL", false); - } - } -} diff --git a/eventmesh-runtime/src/test/java/protocol/CmdRecommendTest.java b/eventmesh-runtime/src/test/java/protocol/CmdRecommendTest.java deleted file mode 100644 index 6973511611..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdRecommendTest.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 protocol; - -import client.PubClient; -import client.common.Server; -import client.common.UserAgentUtils; -import client.impl.PubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -public class CmdRecommendTest { - public static Server server = new Server(); - public static PubClient client = new PubClientImpl("127.0.0.1", 10000, UserAgentUtils.createPubUserAgent()); - - @BeforeClass - public static void before_Cmd_Recommend() throws Exception { - server.startAccessServer(); - client.init(); - Thread.sleep(1000); - } - - @AfterClass - public static void after_Cmd_Recommend() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } - - @Test - public void test_Cmd_Recommend() throws Exception { - - Package replyMsg = client.askRecommend(); - System.err.println("Reply Message-----------------------------------------" + replyMsg.toString()); - if (replyMsg.getHeader().getCommand() != Command.RECOMMEND_RESPONSE) { - Assert.assertTrue("RECOMMEND_RESPONSE FAIL", false); - } - } - - -} diff --git a/eventmesh-runtime/src/test/java/protocol/CmdSendRRTest.java b/eventmesh-runtime/src/test/java/protocol/CmdSendRRTest.java deleted file mode 100644 index 2516437d96..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdSendRRTest.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 protocol; - -import client.PubClient; -import client.SubClient; -import client.common.MessageUtils; -import client.common.Server; -import client.common.UserAgentUtils; -import client.impl.PubClientImpl; -import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -public class CmdSendRRTest { - - public static Server server = new Server(); - public static PubClient client = new PubClientImpl("127.0.0.1", 10000, UserAgentUtils.createPubUserAgent()); - public static SubClient subClient = new SubClientImpl("127.0.0.1", 10000, UserAgentUtils.createUserAgent()); - - @BeforeClass - public static void before_Cmd_RR() throws Exception { - server.startAccessServer(); - client.init(); - Thread.sleep(1000); - } - - @Test - public void test_Cmd_RR() throws Exception { - Package msg = MessageUtils.rrMesssage("FT0-s-80000000-01-0", 0); - Package replyMsg = client.rr(msg, 5000); - System.err.println("收到回复:" + replyMsg.toString()); - if (replyMsg.getHeader().getCommand() != Command.RESPONSE_TO_CLIENT) { - Assert.assertTrue("RESPONSE_TO_CLIENT FAIL", false); - } - Thread.sleep(1000); - } - - @AfterClass - public static void after_Cmd_RR() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } -} diff --git a/eventmesh-runtime/src/test/java/protocol/CmdSubscribeTest.java b/eventmesh-runtime/src/test/java/protocol/CmdSubscribeTest.java deleted file mode 100644 index 3d6a3b2e3f..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdSubscribeTest.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 protocol; - -import client.SubClient; -import client.common.Server; -import client.common.UserAgentUtils; -import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -/** - * Test Cmd: SUBSCRIBE_REQUEST - */ -public class CmdSubscribeTest { - - public static Server server = new Server(); - public static SubClient client = new SubClientImpl("127.0.0.1", 10000, UserAgentUtils.createSubUserAgent()); - - @BeforeClass - public static void before_Cmd_subscribe() throws Exception { - server.startAccessServer(); - client.init(); - Thread.sleep(1000); - } - - @AfterClass - public static void after_Cmd_subscribe() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } - - @Test - public void test_Cmd_subscribe() throws Exception { - Package replyMsg = client.justSubscribe("FT0-s-80000000-01-0"); - System.err.println("Reply Message------------------" + replyMsg.toString()); - if (replyMsg.getHeader().getCommand() != Command.SUBSCRIBE_RESPONSE) { - Assert.assertTrue("SUBSCRIBE_RESPONSE FAIL", false); - } - } -} diff --git a/eventmesh-runtime/src/test/java/protocol/CmdSysLogTest.java b/eventmesh-runtime/src/test/java/protocol/CmdSysLogTest.java deleted file mode 100644 index caf8fce570..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdSysLogTest.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 protocol; - -import client.SubClient; -import client.common.Server; -import client.common.UserAgentUtils; -import client.hook.ReceiveMsgHook; -import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Package; -import io.netty.channel.ChannelHandlerContext; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test Cmd: SYS_LOG_TO_LOGSERVER - */ -public class CmdSysLogTest { - public static Server server = new Server(); - public static SubClient client = new SubClientImpl("127.0.0.1", 10000, UserAgentUtils.createSubUserAgent()); - - @BeforeClass - public static void before_Cmd_syslog() throws Exception { - server.startAccessServer(); - client.init(); - } - - @AfterClass - public static void after_Cmd_syslog() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } - - @Test - public void test_Cmd_syslog() throws Exception { - client.registerBusiHandler(new ReceiveMsgHook() { - @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - System.err.println("receive response from server:------------------" + msg.toString()); - Assert.assertTrue("receive a error command", false); - } - }); -// client.sysLog(); - Thread.sleep(1000); - } -} diff --git a/eventmesh-runtime/src/test/java/protocol/CmdTraceLogTest.java b/eventmesh-runtime/src/test/java/protocol/CmdTraceLogTest.java deleted file mode 100644 index 7255adc3a6..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdTraceLogTest.java +++ /dev/null @@ -1,64 +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 protocol; - -import client.SubClient; -import client.common.Server; -import client.common.UserAgentUtils; -import client.hook.ReceiveMsgHook; -import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Package; -import io.netty.channel.ChannelHandlerContext; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Cmd Test: TRACE_LOG_TO_LOGSERVER - */ -public class CmdTraceLogTest { - - public static Server server = new Server(); - public static SubClient client = new SubClientImpl("127.0.0.1", 10000, UserAgentUtils.createSubUserAgent()); - - @BeforeClass - public static void before_Cmd_traceLog() throws Exception { - server.startAccessServer(); - client.init(); - } - - @AfterClass - public static void after_Cmd_traceLog() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } - - @Test - public void test_Cmd_traceLog() throws Exception { - client.registerBusiHandler(new ReceiveMsgHook() { - @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - System.err.println("receive response from server:------------------" + msg.toString()); - Assert.assertTrue("receive a error command", false); - } - }); -// client.traceLog(); - Thread.sleep(1000); - } -} diff --git a/eventmesh-runtime/src/test/java/protocol/CmdUnSubscribeTest.java b/eventmesh-runtime/src/test/java/protocol/CmdUnSubscribeTest.java deleted file mode 100644 index 4210655195..0000000000 --- a/eventmesh-runtime/src/test/java/protocol/CmdUnSubscribeTest.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 protocol; - -import client.SubClient; -import client.common.Server; -import client.common.UserAgentUtils; -import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Package; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test Cmd: UNSUBSCRIBE_REQUEST - */ -public class CmdUnSubscribeTest { - - public static Server server = new Server(); - public static SubClient client = new SubClientImpl("127.0.0.1", 10000, UserAgentUtils.createSubUserAgent()); - - @BeforeClass - public static void before_Cmd_unsubscribe() throws Exception { - server.startAccessServer(); - client.init(); - Thread.sleep(1000); - } - - @AfterClass - public static void after_Cmd_unsubscribe() throws Exception { -// server.shutdownAccessServer(); -// client.close(); - } - - @Test - public void test_Cmd_unsubscribe() throws Exception { - Package replyMsg = client.justUnsubscribe("FT0-s-80000000-01-0"); - System.err.println("Reply Message-----------------------------------------" + replyMsg.toString()); - if (replyMsg.getHeader().getCommand() != Command.UNSUBSCRIBE_RESPONSE) { - Assert.assertTrue("UNSUBSCRIBE_RESPONSE FAIL", false); - } - } -} diff --git a/eventmesh-runtime/src/test/java/test/BasicTest.java b/eventmesh-runtime/src/test/java/test/BasicTest.java deleted file mode 100644 index a95d3d4f6c..0000000000 --- a/eventmesh-runtime/src/test/java/test/BasicTest.java +++ /dev/null @@ -1,159 +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 test; - -import client.EventMeshClient; -import client.PubClient; -import client.SubClient; -import client.common.MessageUtils; -import client.hook.ReceiveMsgHook; -import client.impl.EventMeshClientImpl; -import client.impl.PubClientImpl; -import client.impl.SubClientImpl; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Package; -import io.netty.channel.ChannelHandlerContext; -import org.junit.Test; - -public class BasicTest { - @Test - public void helloTest() throws Exception { - EventMeshClient client = initClient(); - client.heartbeat(); - client.close(); - } - - @Test - public void heartbeatTest() throws Exception { - EventMeshClient client = initClient(); - client.heartbeat(); - Thread.sleep(4000); - client.close(); - } - - @Test - public void goodbyeTest() throws Exception { - EventMeshClient client = initClient(); - client.heartbeat(); - client.goodbye(); - client.close(); - } - - @Test - public void subscribe() throws Exception { - EventMeshClient client = initClient(); - client.heartbeat(); - client.justSubscribe("FT0-s-80010000-01-1"); - client.close(); - } - - @Test - public void unsubscribe() throws Exception { - EventMeshClient client = initClient(); - client.heartbeat(); - client.justSubscribe("FT0-s-80000000-01-0"); - client.listen(); - client.justUnsubscribe("FT0-s-80000000-01-0"); - client.close(); - } - - @Test - public void listenTest() throws Exception { - EventMeshClient client = initClient(); - client.heartbeat(); - client.listen(); - client.close(); - } - - @Test - public void syncMessage() throws Exception { - EventMeshClient client = initClient(); - client.heartbeat(); - client.justSubscribe("FT0-s-80000000-01-0"); - client.listen(); - for (int i = 0; i < 100; i++) { - Package rr = client.rr(MessageUtils.rrMesssage("FT0-s-80000000-01-0", i), 3000); - if (rr.getBody() instanceof EventMeshMessage) { - String body = ((EventMeshMessage) rr.getBody()).getBody(); - System.err.println("rrMessage: " + body + " " + "rr-reply-------------------------------------------------" + rr.toString()); - } - } - Thread.sleep(100); - client.close(); - } - - @Test - public void asyncMessage() throws Exception { - EventMeshClient client = initClient(); - - client.justSubscribe("FT0-e-80010000-01-1"); - client.heartbeat(); - client.listen(); - client.registerSubBusiHandler(new ReceiveMsgHook() { - @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - if (msg.getBody() instanceof EventMeshMessage) { - String body = ((EventMeshMessage) msg.getBody()).getBody(); - System.err.println("receive message :------" + body + "------------------------------------------------" + msg.toString()); - } - } - }); - System.err.println("before publish"); - client.publish(MessageUtils.asyncMessage("FT0-e-80010000-01-1", 0), 3000); - Thread.sleep(500); - client.close(); - } - - @Test - public void broadcastMessage() throws Exception { - EventMeshClient client = initClient(); - client.heartbeat(); - client.justSubscribe("FT0-e-80030000-01-3"); - client.listen(); - client.registerSubBusiHandler(new ReceiveMsgHook() { - @Override - public void handle(Package msg, ChannelHandlerContext ctx) { - if (msg.getBody() instanceof EventMeshMessage) { - String body = ((EventMeshMessage) msg.getBody()).getBody(); - System.err.println("receive message: ------------" + body + "-------------------------------" + msg.toString()); - } - } - }); - client.broadcast(MessageUtils.broadcastMessage("FT0-e-80030000-01-3", 0), 3000); - Thread.sleep(500); - client.close(); - } - - private PubClient initPubClient() throws Exception { - PubClientImpl pubClient = new PubClientImpl("127.0.0.1", 10000, MessageUtils.generatePubClient()); - pubClient.init(); - return pubClient; - } - - private SubClient initSubClient() throws Exception { - SubClientImpl subClient = new SubClientImpl("127.0.0.1", 10000, MessageUtils.generateSubServer()); - subClient.init(); - return subClient; - } - - private EventMeshClient initClient() throws Exception { - EventMeshClientImpl client = new EventMeshClientImpl("127.0.0.1", 10000); - client.init(); - return client; - } -} diff --git a/eventmesh-sdk-java/build.gradle b/eventmesh-sdk-java/build.gradle index fe66fd0d53..70a51362e6 100644 --- a/eventmesh-sdk-java/build.gradle +++ b/eventmesh-sdk-java/build.gradle @@ -21,52 +21,14 @@ //} -apply plugin: 'java' -apply plugin: "maven" -apply plugin: "eclipse" -apply plugin: "idea" +//ext['commons-pool2.version'] = '2.6.1' -if (project.findProperty("jdk") == "1.7") { - sourceCompatibility = 1.7 - targetCompatibility = 1.7 -} else { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - version = version + "-jdk8" -} - -if (project.findProperty("snapshot") instanceof String) { - if (project.property("snapshot").toBoolean()) version = version + "-SNAPSHOT" -} - -repositories { - mavenLocal() - maven { - url "https://maven.aliyun.com/repository/public" - } - mavenCentral() -} - -ext['commons-pool2.version'] = '2.6.1' - -List log4j2 = [ - "org.apache.logging.log4j:log4j-api:2.13.3", - "org.apache.logging.log4j:log4j-core:2.13.3", - "org.apache.logging.log4j:log4j-slf4j-impl:2.13.3", - "org.apache.logging.log4j:log4j-web:2.13.3", - "com.lmax:disruptor:3.4.2" -] - -List sl4j = [ - "org.slf4j:slf4j-api:1.7.30" -] - dependencies { - compile log4j2, sl4j - testCompile log4j2, sl4j - compile project(":eventmesh-common") - testCompile project(":eventmesh-common") + //implementation log4j2, sl4j,httpclient,netty + // log4j2, sl4j,httpclient,netty + implementation project(":eventmesh-common") + testImplementation project(":eventmesh-common") // //Spring依赖的第三方模块(2.1.6依赖的是3.8.1) // compile("org.apache.commons:commons-lang3") @@ -84,43 +46,3 @@ dependencies { // } } -configurations.all{ - exclude group: "ch.qos.logback" -} - -//uploadArchives { -// repositories { -// mavenDeployer { -//// snapshotRepository(url: 'Your target repo address') { -//// authentication(userName: 'Your user name', password: 'Your password') -//// } -//// repository(url: 'Your target repo address') { -//// authentication(userName: 'Your user name', password: 'Your password') -//// } -// } -// } -//} - -task zip(type: Zip, dependsOn: ['clean', 'jar']) { - extension = 'zip' - archiveName = project.name + '_' + version + '.' + extension - destinationDir = new File(projectDir, 'dist') - - into("/") { - from project.jar.getArchivePath() - } -} - -task tar(type: Tar, dependsOn: ['clean', 'jar']) { - extension = 'tar.gz' - compression = Compression.GZIP - archiveName = project.name + '_' + version + '.' + extension - destinationDir = new File(projectDir, 'dist') - into("/") { - from project.jar.getArchivePath() - } -} - -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" -} \ No newline at end of file diff --git a/eventmesh-sdk-java/gradle.properties b/eventmesh-sdk-java/gradle.properties index 0b0cdce4c5..d0503c3b7b 100644 --- a/eventmesh-sdk-java/gradle.properties +++ b/eventmesh-sdk-java/gradle.properties @@ -14,8 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # - -group=com.webank.eventmesh +group=org.apache.eventmesh version=1.2.0-SNAPSHOT jdk=1.8 snapshot=false diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/AbstractLiteClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/AbstractLiteClient.java similarity index 92% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/AbstractLiteClient.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/AbstractLiteClient.java index 9b8e04dc14..261fbb423c 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/AbstractLiteClient.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/AbstractLiteClient.java @@ -15,21 +15,22 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http; +package org.apache.eventmesh.client.http; + +import java.util.Arrays; +import java.util.List; -import com.webank.eventmesh.client.http.conf.LiteClientConfig; -import com.webank.eventmesh.common.EventMeshException; import com.google.common.collect.Lists; + import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.client.http.conf.LiteClientConfig; +import org.apache.eventmesh.common.EventMeshException; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Arrays; -import java.util.List; - public abstract class AbstractLiteClient { public Logger logger = LoggerFactory.getLogger(AbstractLiteClient.class); @@ -52,7 +53,7 @@ public AbstractLiteClient(LiteClientConfig liteClientConfig) { public void start() throws Exception { eventMeshServerList = process(liteClientConfig.getLiteEventMeshAddr()); - if(eventMeshServerList == null || eventMeshServerList.size() < 1){ + if (eventMeshServerList == null || eventMeshServerList.size() < 1) { throw new EventMeshException("liteEventMeshAddr param illegal,please check"); } } diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/EventMeshRetObj.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/EventMeshRetObj.java similarity index 96% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/EventMeshRetObj.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/EventMeshRetObj.java index 21a295e424..fe024fcf5f 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/EventMeshRetObj.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/EventMeshRetObj.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http; +package org.apache.eventmesh.client.http; public class EventMeshRetObj { diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/RemotingServer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/RemotingServer.java similarity index 89% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/RemotingServer.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/RemotingServer.java index a8c4683d36..e85937e9ef 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/RemotingServer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/RemotingServer.java @@ -15,47 +15,66 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http; -import com.webank.eventmesh.client.http.consumer.HandleResult; -import com.webank.eventmesh.client.http.consumer.context.LiteConsumeContext; -import com.webank.eventmesh.client.http.consumer.listener.LiteMessageListener; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.LiteMessage; -import com.webank.eventmesh.common.ThreadUtil; -import com.webank.eventmesh.common.command.HttpCommand; -import com.webank.eventmesh.common.protocol.http.body.Body; -import com.webank.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; -import com.webank.eventmesh.common.protocol.http.common.ClientRetCode; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; -import com.webank.eventmesh.common.protocol.http.header.Header; -import com.webank.eventmesh.common.protocol.http.header.message.PushMessageRequestHeader; +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.*; +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.*; +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; -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; - public class RemotingServer { public Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -138,9 +157,6 @@ public String getEndpointURL() { } - - - class HTTPHandler extends SimpleChannelInboundHandler { /** @@ -213,7 +229,7 @@ protected void channelRead0(final ChannelHandlerContext ctx, HttpRequest httpReq 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))) { + && !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()); diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/conf/LiteClientConfig.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/conf/LiteClientConfig.java similarity index 98% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/conf/LiteClientConfig.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/conf/LiteClientConfig.java index 23febec8ee..21140b2ab8 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/conf/LiteClientConfig.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/conf/LiteClientConfig.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http.conf; +package org.apache.eventmesh.client.http.conf; public class LiteClientConfig { diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/consumer/HandleResult.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/HandleResult.java similarity index 94% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/consumer/HandleResult.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/HandleResult.java index 0b88101989..c5a9a85bd3 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/consumer/HandleResult.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/HandleResult.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http.consumer; +package org.apache.eventmesh.client.http.consumer; public enum HandleResult { OK, diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/consumer/LiteConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/LiteConsumer.java similarity index 90% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/consumer/LiteConsumer.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/LiteConsumer.java index 8fe0950dbe..801481a418 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/consumer/LiteConsumer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/LiteConsumer.java @@ -15,42 +15,48 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http.consumer; +package org.apache.eventmesh.client.http.consumer; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.webank.eventmesh.client.http.AbstractLiteClient; -import com.webank.eventmesh.client.http.EventMeshRetObj; -import com.webank.eventmesh.client.http.RemotingServer; -import com.webank.eventmesh.client.http.conf.LiteClientConfig; -import com.webank.eventmesh.client.http.consumer.listener.LiteMessageListener; -import com.webank.eventmesh.client.http.http.HttpUtil; -import com.webank.eventmesh.client.http.http.RequestParam; -import com.webank.eventmesh.client.tcp.common.EventMeshCommon; -import com.webank.eventmesh.client.tcp.common.EventMeshThreadFactoryImpl; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.EventMeshException; -import com.webank.eventmesh.common.ThreadPoolFactory; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; -import com.webank.eventmesh.common.protocol.http.body.client.HeartbeatRequestBody; -import com.webank.eventmesh.common.protocol.http.body.client.SubscribeRequestBody; -import com.webank.eventmesh.common.protocol.http.common.*; + import io.netty.handler.codec.http.HttpMethod; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.RandomUtils; +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.http.body.client.HeartbeatRequestBody; +import org.apache.eventmesh.common.protocol.http.body.client.SubscribeRequestBody; +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.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - public class LiteConsumer extends AbstractLiteClient { public Logger logger = LoggerFactory.getLogger(LiteConsumer.class); @@ -111,7 +117,7 @@ public void shutdown() throws Exception { public boolean subscribe(List topicList, String url) throws Exception { subscription.addAll(topicList); - if(!started.get()) { + if (!started.get()) { start(); } @@ -129,7 +135,7 @@ public boolean subscribe(List topicList, String url) throws Exception { throw new EventMeshException(ex); } - if(logger.isDebugEnabled()) { + if (logger.isDebugEnabled()) { logger.debug("subscribe message by await, targetEventMesh:{}, cost:{}ms, subscribeParam:{}, rtn:{}", target, System.currentTimeMillis() - startTime, JSON.toJSONString(subscribeParam), subRes); } @@ -169,7 +175,7 @@ private RequestParam generateSubscribeRequestParam(List topicList, Strin private RequestParam generateHeartBeatRequestParam(List topics, String url) { List heartbeatEntities = new ArrayList<>(); - for (String topic : topics){ + for (String topic : topics) { HeartbeatRequestBody.HeartbeatEntity heartbeatEntity = new HeartbeatRequestBody.HeartbeatEntity(); heartbeatEntity.topic = topic; heartbeatEntity.url = url; @@ -200,7 +206,7 @@ public void heartBeat(List topicList, String url) throws Exception { @Override public void run() { try { - if(!started.get()) { + if (!started.get()) { start(); } RequestParam requestParam = generateHeartBeatRequestParam(topicList, url); @@ -214,7 +220,7 @@ public void run() { throw new EventMeshException(ex); } - if(logger.isDebugEnabled()) { + if (logger.isDebugEnabled()) { logger.debug("heartBeat message by await, targetEventMesh:{}, cost:{}ms, rtn:{}", target, System.currentTimeMillis() - startTime, res); } @@ -247,7 +253,7 @@ public boolean unsubscribe(List topicList, String url) throws EventMeshE throw new EventMeshException(ex); } - if(logger.isDebugEnabled()) { + if (logger.isDebugEnabled()) { logger.debug("unSubscribe message by await, targetEventMesh:{}, cost:{}ms, unSubscribeParam:{}, rtn:{}", target, System.currentTimeMillis() - startTime, JSON.toJSONString(unSubscribeParam), unSubRes); } @@ -289,9 +295,9 @@ public String selectEventMesh() { if (CollectionUtils.isEmpty(eventMeshServerList)) { return null; } - if(liteClientConfig.isUseTls()){ + if (liteClientConfig.isUseTls()) { return Constants.HTTPS_PROTOCOL_PREFIX + eventMeshServerList.get(RandomUtils.nextInt(0, eventMeshServerList.size())); - }else{ + } else { return Constants.HTTP_PROTOCOL_PREFIX + eventMeshServerList.get(RandomUtils.nextInt(0, eventMeshServerList.size())); } } diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/consumer/context/LiteConsumeContext.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/context/LiteConsumeContext.java similarity index 95% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/consumer/context/LiteConsumeContext.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/context/LiteConsumeContext.java index 0157a24090..42739ca0a9 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/consumer/context/LiteConsumeContext.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/context/LiteConsumeContext.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http.consumer.context; +package org.apache.eventmesh.client.http.consumer.context; -import com.webank.eventmesh.common.Constants; import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.common.Constants; public class LiteConsumeContext { @@ -40,7 +40,7 @@ public class LiteConsumeContext { private long createTime = System.currentTimeMillis(); public LiteConsumeContext(String eventMeshIp, String eventMeshEnv, - String eventMeshIdc,String eventMeshRegion, + String eventMeshIdc, String eventMeshRegion, String eventMeshCluster, String eventMeshDcn) { this.eventMeshIp = eventMeshIp; this.eventMeshEnv = eventMeshEnv; diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/consumer/listener/LiteMessageListener.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/listener/LiteMessageListener.java similarity index 80% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/consumer/listener/LiteMessageListener.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/listener/LiteMessageListener.java index 3e2aa367d8..c7f5ac99af 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/consumer/listener/LiteMessageListener.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/listener/LiteMessageListener.java @@ -15,11 +15,12 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http.consumer.listener; +package org.apache.eventmesh.client.http.consumer.listener; -import com.webank.eventmesh.client.http.consumer.HandleResult; -import com.webank.eventmesh.client.http.consumer.context.LiteConsumeContext; -import com.webank.eventmesh.common.LiteMessage; + +import org.apache.eventmesh.client.http.consumer.HandleResult; +import org.apache.eventmesh.client.http.consumer.context.LiteConsumeContext; +import org.apache.eventmesh.common.LiteMessage; public interface LiteMessageListener { diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/http/HttpUtil.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/http/HttpUtil.java similarity index 98% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/http/HttpUtil.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/http/HttpUtil.java index 7340ca81ba..4093a89ea1 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/http/HttpUtil.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/http/HttpUtil.java @@ -15,12 +15,23 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http.http; -import com.webank.eventmesh.common.Constants; +package org.apache.eventmesh.client.http.http; + +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.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; @@ -35,14 +46,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -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; - public class HttpUtil { public static Logger logger = LoggerFactory.getLogger(HttpUtil.class); @@ -133,7 +136,7 @@ public static void post(CloseableHttpClient client, .setConnectTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))) .setConnectionRequestTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))); - if(forwardAgent != null) { + if (forwardAgent != null) { configBuilder.setProxy(forwardAgent); } @@ -176,7 +179,7 @@ public static void get(CloseableHttpClient client, .setConnectTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))) .setConnectionRequestTimeout(Integer.parseInt(String.valueOf(requestParam.getTimeout()))); - if(forwardAgent != null) { + if (forwardAgent != null) { configBuilder.setProxy(forwardAgent); } diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/http/RequestParam.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/http/RequestParam.java similarity index 98% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/http/RequestParam.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/http/RequestParam.java index ce03e0be51..4d23222352 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/http/RequestParam.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/http/RequestParam.java @@ -15,11 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http.http; - -import io.netty.handler.codec.http.HttpMethod; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.eventmesh.client.http.http; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -27,6 +23,11 @@ import java.util.HashMap; import java.util.Map; +import io.netty.handler.codec.http.HttpMethod; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class RequestParam { public Logger logger = LoggerFactory.getLogger(this.getClass()); diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/producer/LiteProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/LiteProducer.java similarity index 88% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/producer/LiteProducer.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/LiteProducer.java index 460a39c536..3b4ecc2384 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/producer/LiteProducer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/LiteProducer.java @@ -15,43 +15,48 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http.producer; +package org.apache.eventmesh.client.http.producer; + +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.concurrent.atomic.AtomicBoolean; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; + -import com.webank.eventmesh.client.http.AbstractLiteClient; -import com.webank.eventmesh.client.http.EventMeshRetObj; -import com.webank.eventmesh.client.http.conf.LiteClientConfig; -import com.webank.eventmesh.client.http.http.HttpUtil; -import com.webank.eventmesh.client.http.http.RequestParam; -import com.webank.eventmesh.client.http.ssl.MyX509TrustManager; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.LiteMessage; -import com.webank.eventmesh.common.EventMeshException; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageRequestBody; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; -import com.webank.eventmesh.common.protocol.http.common.ProtocolKey; -import com.webank.eventmesh.common.protocol.http.common.ProtocolVersion; -import com.webank.eventmesh.common.protocol.http.common.EventMeshRetCode; -import com.webank.eventmesh.common.protocol.http.common.RequestCode; import com.alibaba.fastjson.JSON; import com.google.common.base.Preconditions; + import io.netty.handler.codec.http.HttpMethod; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.StringUtils; +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.client.http.ssl.MyX509TrustManager; +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.http.conn.ssl.DefaultHostnameVerifier; +import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; 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.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.util.concurrent.atomic.AtomicBoolean; - public class LiteProducer extends AbstractLiteClient { public Logger logger = LoggerFactory.getLogger(LiteProducer.class); @@ -60,7 +65,7 @@ public class LiteProducer extends AbstractLiteClient { public LiteProducer(LiteClientConfig liteClientConfig) { super(liteClientConfig); - if(liteClientConfig.isUseTls()){ + if (liteClientConfig.isUseTls()) { setHttpClient(); } } @@ -71,7 +76,7 @@ public LiteProducer(LiteClientConfig liteClientConfig) { 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()) { + if (started.get()) { return; } logger.info("LiteProducer starting"); @@ -82,7 +87,7 @@ public void start() throws Exception { @Override public void shutdown() throws Exception { - if(!started.get()) { + if (!started.get()) { return; } logger.info("LiteProducer shutting down"); @@ -133,7 +138,7 @@ public boolean publish(LiteMessage message) throws Exception { throw new EventMeshException(ex); } - if(logger.isDebugEnabled()) { + if (logger.isDebugEnabled()) { logger.debug("publish async message, targetEventMesh:{}, cost:{}ms, message:{}, rtn:{}", target, System.currentTimeMillis() - startTime, message, res); } @@ -151,15 +156,15 @@ public String selectEventMesh() { if (CollectionUtils.isEmpty(eventMeshServerList)) { return null; } - if(liteClientConfig.isUseTls()){ + if (liteClientConfig.isUseTls()) { return Constants.HTTPS_PROTOCOL_PREFIX + eventMeshServerList.get(RandomUtils.nextInt(0, eventMeshServerList.size())); - }else{ + } else { return Constants.HTTP_PROTOCOL_PREFIX + eventMeshServerList.get(RandomUtils.nextInt(0, eventMeshServerList.size())); } } public LiteMessage request(LiteMessage message, long timeout) throws Exception { - if(!started.get()) { + if (!started.get()) { start(); } Preconditions.checkState(StringUtils.isNotBlank(message.getTopic()), @@ -195,7 +200,7 @@ public LiteMessage request(LiteMessage message, long timeout) throws Exception { throw new EventMeshException(ex); } - if(logger.isDebugEnabled()) { + if (logger.isDebugEnabled()) { logger.debug("publish sync message by await, targetEventMesh:{}, cost:{}ms, message:{}, rtn:{}", target, System.currentTimeMillis() - startTime, message, res); } @@ -213,7 +218,7 @@ public LiteMessage request(LiteMessage message, long timeout) throws Exception { } public void request(LiteMessage message, RRCallback rrCallback, long timeout) throws Exception { - if(!started.get()) { + if (!started.get()) { start(); } Preconditions.checkState(StringUtils.isNotBlank(message.getTopic()), @@ -250,7 +255,7 @@ public void request(LiteMessage message, RRCallback rrCallback, long timeout) th throw new EventMeshException(ex); } - if(logger.isDebugEnabled()) { + if (logger.isDebugEnabled()) { logger.debug("publish sync message by async, target:{}, cost:{}, message:{}", target, System.currentTimeMillis() - startTime, message); } } @@ -259,11 +264,11 @@ public static void setHttpClient() { SSLContext sslContext = null; try { String protocol = System.getProperty("ssl.client.protocol", "TLSv1.1"); - TrustManager[] tm = new TrustManager[] { new MyX509TrustManager() }; + TrustManager[] tm = new TrustManager[]{new MyX509TrustManager()}; sslContext = SSLContext.getInstance(protocol); sslContext.init(null, tm, new SecureRandom()); - httpClient = HttpClients.custom().setSslcontext(sslContext) - .setHostnameVerifier(SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER).build(); + httpClient = HttpClients.custom().setSSLContext(sslContext) + .setSSLHostnameVerifier(new DefaultHostnameVerifier()).build(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyManagementException e) { diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/producer/RRCallback.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallback.java similarity index 90% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/producer/RRCallback.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallback.java index 53fbaea84c..c5187984de 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/producer/RRCallback.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallback.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http.producer; +package org.apache.eventmesh.client.http.producer; -import com.webank.eventmesh.common.LiteMessage; +import org.apache.eventmesh.common.LiteMessage; public interface RRCallback { diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/producer/RRCallbackResponseHandlerAdapter.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallbackResponseHandlerAdapter.java similarity index 90% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/producer/RRCallbackResponseHandlerAdapter.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallbackResponseHandlerAdapter.java index 846fa1531e..aba948bc32 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/producer/RRCallbackResponseHandlerAdapter.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/producer/RRCallbackResponseHandlerAdapter.java @@ -15,16 +15,21 @@ * limitations under the License. */ -package com.webank.eventmesh.client.http.producer; - -import com.webank.eventmesh.client.http.EventMeshRetObj; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.LiteMessage; -import com.webank.eventmesh.common.EventMeshException; -import com.webank.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; -import com.webank.eventmesh.common.protocol.http.common.EventMeshRetCode; +package org.apache.eventmesh.client.http.producer; + +import java.io.IOException; +import java.nio.charset.Charset; + + import com.alibaba.fastjson.JSON; + import org.apache.commons.lang3.time.DateFormatUtils; +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.protocol.http.body.message.SendMessageResponseBody; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.ClientProtocolException; @@ -33,9 +38,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.nio.charset.Charset; - public class RRCallbackResponseHandlerAdapter implements ResponseHandler { public Logger logger = LoggerFactory.getLogger(RRCallbackResponseHandlerAdapter.class); diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/ssl/MyX509TrustManager.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/ssl/MyX509TrustManager.java similarity index 68% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/ssl/MyX509TrustManager.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/ssl/MyX509TrustManager.java index 8576f57aaa..6128b38fd0 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/http/ssl/MyX509TrustManager.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/ssl/MyX509TrustManager.java @@ -1,6 +1,22 @@ -package com.webank.eventmesh.client.http.ssl; +/* + * Licensed 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.ssl; -import org.apache.commons.lang3.StringUtils; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; @@ -12,15 +28,18 @@ import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; + +import org.apache.commons.lang3.StringUtils; + public class MyX509TrustManager implements X509TrustManager { X509TrustManager myTrustManager; public MyX509TrustManager() throws Exception { KeyStore keyStore = KeyStore.getInstance("JKS"); - String fileName = System.getProperty("ssl.client.cer","sChat2.jks"); + String fileName = System.getProperty("ssl.client.cer", "sChat2.jks"); String pass = System.getProperty("ssl.client.pass", "sNetty"); char[] filePass = null; - if(StringUtils.isNotBlank(pass)){ + if (StringUtils.isNotBlank(pass)) { filePass = pass.toCharArray(); } keyStore.load(Files.newInputStream(Paths.get(System.getProperty("confPath", System.getenv("confPath")) diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/EventMeshClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshClient.java similarity index 87% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/EventMeshClient.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshClient.java index e98925e45a..4e11260528 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/EventMeshClient.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/EventMeshClient.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp; +package org.apache.eventmesh.client.tcp; -import com.webank.eventmesh.client.tcp.common.AsyncRRCallback; -import com.webank.eventmesh.client.tcp.common.ReceiveMsgHook; -import com.webank.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.client.tcp.common.AsyncRRCallback; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.common.protocol.tcp.Package; public interface EventMeshClient { diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/SimplePubClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/SimplePubClient.java similarity index 82% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/SimplePubClient.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/SimplePubClient.java index 072b121b91..239cfa423d 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/SimplePubClient.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/SimplePubClient.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp; +package org.apache.eventmesh.client.tcp; -import com.webank.eventmesh.client.tcp.common.AsyncRRCallback; -import com.webank.eventmesh.client.tcp.common.ReceiveMsgHook; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import com.webank.eventmesh.common.protocol.tcp.Package; +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 { diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/SimpleSubClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/SimpleSubClient.java similarity index 61% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/SimpleSubClient.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/SimpleSubClient.java index 04b1006994..251fd93b27 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/SimpleSubClient.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/SimpleSubClient.java @@ -15,28 +15,28 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp; +package org.apache.eventmesh.client.tcp; -import com.webank.eventmesh.client.tcp.common.ReceiveMsgHook; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; public interface SimpleSubClient { - void init() throws Exception; + void init() throws Exception; - void close(); + void close(); - void heartbeat() throws Exception; + void heartbeat() throws Exception; - void reconnect() throws Exception; + void reconnect() throws Exception; - void subscribe(String topic) throws Exception; + void subscribe(String topic) throws Exception; - void unsubscribe() throws Exception; + void unsubscribe() throws Exception; - void listen() throws Exception; + void listen() throws Exception; - void registerBusiHandler(ReceiveMsgHook handler) throws Exception; + void registerBusiHandler(ReceiveMsgHook handler) throws Exception; - UserAgent getUserAgent(); + UserAgent getUserAgent(); } diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/AsyncRRCallback.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/AsyncRRCallback.java similarity index 89% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/AsyncRRCallback.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/AsyncRRCallback.java index 39621f58bd..135e88dd88 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/AsyncRRCallback.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/AsyncRRCallback.java @@ -15,8 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp.common; -import com.webank.eventmesh.common.protocol.tcp.Package; +package org.apache.eventmesh.client.tcp.common; public interface AsyncRRCallback { void callback(Package msg); diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/EventMeshCommon.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshCommon.java similarity index 98% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/EventMeshCommon.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshCommon.java index 2d9d8a9c00..65aa40e918 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/EventMeshCommon.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshCommon.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp.common; +package org.apache.eventmesh.client.tcp.common; public class EventMeshCommon { /** diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/EventMeshThreadFactoryImpl.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshThreadFactoryImpl.java similarity index 92% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/EventMeshThreadFactoryImpl.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshThreadFactoryImpl.java index 89ab987087..49692baa92 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/EventMeshThreadFactoryImpl.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshThreadFactoryImpl.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp.common; +package org.apache.eventmesh.client.tcp.common; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicLong; @@ -40,7 +40,7 @@ public String getThreadNamePrefix() { @Override public Thread newThread(Runnable r) { - Thread t = new Thread(r, threadNamePrefix +'-'+ this.threadIndex.incrementAndGet()); + Thread t = new Thread(r, threadNamePrefix + '-' + this.threadIndex.incrementAndGet()); if (isDaemonSpecified != null) { t.setDaemon(isDaemonSpecified); } diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/MessageUtils.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/MessageUtils.java similarity index 93% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/MessageUtils.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/MessageUtils.java index 261deaa3e5..4122a234a0 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/MessageUtils.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/MessageUtils.java @@ -15,17 +15,18 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp.common; +package org.apache.eventmesh.client.tcp.common; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.Subscription; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import com.webank.eventmesh.common.protocol.tcp.Package; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ThreadLocalRandom; +import org.apache.eventmesh.common.protocol.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.Header; +import org.apache.eventmesh.common.protocol.tcp.Subscription; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.common.protocol.tcp.Package; + public class MessageUtils { private static final int seqLength = 10; @@ -145,4 +146,3 @@ private static String generateRandomString(int length) { return builder.toString(); } } - diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/ReceiveMsgHook.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/ReceiveMsgHook.java similarity index 90% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/ReceiveMsgHook.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/ReceiveMsgHook.java index 24e8a92e15..bc60a6a8a2 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/ReceiveMsgHook.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/ReceiveMsgHook.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp.common; +package org.apache.eventmesh.client.tcp.common; import io.netty.channel.ChannelHandlerContext; -import com.webank.eventmesh.common.protocol.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.Package; public interface ReceiveMsgHook { void handle(Package msg, ChannelHandlerContext ctx); diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/RequestContext.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/RequestContext.java similarity index 96% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/RequestContext.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/RequestContext.java index d58dc32781..ae36e6a746 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/RequestContext.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/RequestContext.java @@ -15,12 +15,13 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp.common; +package org.apache.eventmesh.client.tcp.common; +import java.util.concurrent.CountDownLatch; + +import org.apache.eventmesh.common.protocol.tcp.Package; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.webank.eventmesh.common.protocol.tcp.Package; -import java.util.concurrent.CountDownLatch; public class RequestContext { diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/TcpClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java similarity index 83% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/TcpClient.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java index 252855c19d..7df1e29f30 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/common/TcpClient.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java @@ -15,23 +15,39 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp.common; +package org.apache.eventmesh.client.tcp.common; + +import java.io.Closeable; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; -import com.webank.eventmesh.common.protocol.tcp.codec.Codec; import io.netty.bootstrap.Bootstrap; import io.netty.buffer.PooledByteBufAllocator; -import io.netty.channel.*; +import io.netty.channel.AdaptiveRecvByteBufAllocator; +import io.netty.channel.Channel; +import io.netty.channel.ChannelDuplexHandler; +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.NioSocketChannel; + +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; -import com.webank.eventmesh.common.protocol.tcp.Package; -import java.io.Closeable; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.util.Random; -import java.util.concurrent.*; public abstract class TcpClient implements Closeable { private Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -53,7 +69,7 @@ public abstract class TcpClient implements Closeable { private ScheduledFuture task; - public TcpClient(String host, int port){ + public TcpClient(String host, int port) { this.host = host; this.port = port; } @@ -130,7 +146,7 @@ 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); + logger.info("exceptionCaught, close connection.|remote address={}", ctx.channel().remoteAddress(), cause); ctx.close(); } }; diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/impl/DefaultEventMeshClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/DefaultEventMeshClient.java similarity index 87% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/impl/DefaultEventMeshClient.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/DefaultEventMeshClient.java index c7b2080ee9..4cc14eb46a 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/impl/DefaultEventMeshClient.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/DefaultEventMeshClient.java @@ -15,17 +15,17 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp.impl; +package org.apache.eventmesh.client.tcp.impl; -import com.webank.eventmesh.client.tcp.SimplePubClient; -import com.webank.eventmesh.client.tcp.SimpleSubClient; -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.AsyncRRCallback; -import com.webank.eventmesh.client.tcp.common.MessageUtils; -import com.webank.eventmesh.client.tcp.common.ReceiveMsgHook; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import com.webank.eventmesh.common.protocol.tcp.Package; +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.tcp.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; public class DefaultEventMeshClient implements EventMeshClient { protected UserAgent agent; diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/impl/SimplePubClientImpl.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimplePubClientImpl.java similarity index 90% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/impl/SimplePubClientImpl.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimplePubClientImpl.java index ba732c5124..da5691a79f 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/impl/SimplePubClientImpl.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimplePubClientImpl.java @@ -15,28 +15,30 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp.impl; - -import com.webank.eventmesh.client.tcp.SimplePubClient; -import com.webank.eventmesh.client.tcp.common.AsyncRRCallback; -import com.webank.eventmesh.client.tcp.common.MessageUtils; -import com.webank.eventmesh.client.tcp.common.ReceiveMsgHook; -import com.webank.eventmesh.client.tcp.common.RequestContext; -import com.webank.eventmesh.client.tcp.common.TcpClient; -import com.webank.eventmesh.client.tcp.common.EventMeshCommon; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; +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; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; -import com.webank.eventmesh.common.protocol.tcp.Package; - public class SimplePubClientImpl extends TcpClient implements SimplePubClient { private Logger logger = LoggerFactory.getLogger(this.getClass()); diff --git a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/impl/SimpleSubClientImpl.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimpleSubClientImpl.java similarity index 91% rename from eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/impl/SimpleSubClientImpl.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimpleSubClientImpl.java index 51ca21f31e..0579184156 100644 --- a/eventmesh-sdk-java/src/main/java/com/webank/eventmesh/client/tcp/impl/SimpleSubClientImpl.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimpleSubClientImpl.java @@ -15,29 +15,31 @@ * limitations under the License. */ -package com.webank.eventmesh.client.tcp.impl; - -import com.webank.eventmesh.client.tcp.SimpleSubClient; -import com.webank.eventmesh.client.tcp.common.MessageUtils; -import com.webank.eventmesh.client.tcp.common.ReceiveMsgHook; -import com.webank.eventmesh.client.tcp.common.RequestContext; -import com.webank.eventmesh.client.tcp.common.TcpClient; -import com.webank.eventmesh.client.tcp.common.EventMeshCommon; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; +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.tcp.Command; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; +import org.apache.eventmesh.common.protocol.tcp.Package; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; -import com.webank.eventmesh.common.protocol.tcp.Package; - public class SimpleSubClientImpl extends TcpClient implements SimpleSubClient { private Logger logger = LoggerFactory.getLogger(this.getClass()); diff --git a/eventmesh-sdk-java/src/main/resources/log4j2.xml b/eventmesh-sdk-java/src/main/resources/log4j2.xml index e3f037b9cb..90f56982b0 100644 --- a/eventmesh-sdk-java/src/main/resources/log4j2.xml +++ b/eventmesh-sdk-java/src/main/resources/log4j2.xml @@ -28,7 +28,7 @@ - + diff --git a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/common/EventMeshTestCaseTopicSet.java b/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/common/EventMeshTestCaseTopicSet.java deleted file mode 100644 index 2699be30cb..0000000000 --- a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/common/EventMeshTestCaseTopicSet.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.webank.eventmesh.client.tcp.common; - -/** - * Testcase set - */ -public class EventMeshTestCaseTopicSet { - -// public static final String TOPIC_PRX_WQ2ClientBroadCast = "topic-broadcast-test"; - public static final String TOPIC_PRX_WQ2ClientBroadCast = "FT0-e-80030001-01-3"; - -// public static final String TOPIC_PRX_SyncSubscribeTest = "topic-sync-test"; - public static final String TOPIC_PRX_SyncSubscribeTest = "FT0-s-80000000-01-0"; - -// public static final String TOPIC_PRX_WQ2ClientUniCast = "topic-async-test"; - public static final String TOPIC_PRX_WQ2ClientUniCast = "FT0-e-80010000-01-1"; - -} diff --git a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/AsyncPublish.java b/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/AsyncPublish.java deleted file mode 100644 index 009c5f6de4..0000000000 --- a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/AsyncPublish.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.webank.eventmesh.client.tcp.demo; - -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.EventMeshTestUtils; -import com.webank.eventmesh.client.tcp.common.EventMeshCommon; -import com.webank.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AsyncPublish{ - - public static Logger logger = LoggerFactory.getLogger(AsyncPublish.class); - - private static EventMeshClient client; - - public static AsyncPublish handler = new AsyncPublish(); - - 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(); - - 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); - - Thread.sleep(1000); - } - - Thread.sleep(2000); - //退出,销毁资源 -// client.close(); - }catch (Exception e){ - logger.warn("AsyncPublish failed", e); - } - } -} diff --git a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/AsyncPublishBroadcast.java b/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/AsyncPublishBroadcast.java deleted file mode 100644 index fb2c45e088..0000000000 --- a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/AsyncPublishBroadcast.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.webank.eventmesh.client.tcp.demo; - -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.EventMeshTestUtils; -import com.webank.eventmesh.client.tcp.common.EventMeshCommon; -import com.webank.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.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); - //退出,销毁资源 -// client.close(); - }catch (Exception e){ - logger.warn("AsyncPublishBroadcast failed", e); - } - } -} diff --git a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/AsyncSubscribe.java b/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/AsyncSubscribe.java deleted file mode 100644 index 1dd980cfc7..0000000000 --- a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/AsyncSubscribe.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.webank.eventmesh.client.tcp.demo; - -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.EventMeshTestUtils; -import com.webank.eventmesh.client.tcp.common.ReceiveMsgHook; -import com.webank.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import io.netty.channel.ChannelHandlerContext; -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("FT0-e-80010000-01-1"); - client.registerSubBusiHandler(handler); - - client.listen(); - - //client.unsubscribe(); - - //退出,销毁资源 -// 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/com/webank/eventmesh/client/tcp/demo/AsyncSubscribeBroadcast.java b/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/AsyncSubscribeBroadcast.java deleted file mode 100644 index bb4fb56f93..0000000000 --- a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/AsyncSubscribeBroadcast.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.webank.eventmesh.client.tcp.demo; - -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.EventMeshTestUtils; -import com.webank.eventmesh.client.tcp.common.ReceiveMsgHook; -import com.webank.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import io.netty.channel.ChannelHandlerContext; -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("FT0-e-80030001-01-3"); - client.registerSubBusiHandler(handler); - - client.listen(); - - //client.unsubscribe(); - - //退出,销毁资源 -// 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/com/webank/eventmesh/client/tcp/demo/SyncRequest.java b/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/SyncRequest.java deleted file mode 100644 index ad84b1405d..0000000000 --- a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/SyncRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.webank.eventmesh.client.tcp.demo; - -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.EventMeshTestUtils; -import com.webank.eventmesh.client.tcp.common.EventMeshCommon; -import com.webank.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -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); - - //退出,销毁资源 -// client.close(); - }catch (Exception e){ - logger.warn("SyncRequest failed", e); - } - } -} diff --git a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/SyncResponse.java b/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/SyncResponse.java deleted file mode 100644 index fac84e9390..0000000000 --- a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/demo/SyncResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.webank.eventmesh.client.tcp.demo; - -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.EventMeshTestUtils; -import com.webank.eventmesh.client.tcp.common.ReceiveMsgHook; -import com.webank.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import io.netty.channel.ChannelHandlerContext; -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("FT0-s-80000000-01-0"); - //同步RR消息 - client.registerSubBusiHandler(handler); - - client.listen(); - - //client.unsubscribe(); - - //退出,销毁资源 -// 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/com/webank/eventmesh/client/http/demo/AsyncPublishInstance.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncPublishInstance.java similarity index 61% rename from eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/http/demo/AsyncPublishInstance.java rename to eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncPublishInstance.java index 7722fc0fe0..9eaf745742 100644 --- a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/http/demo/AsyncPublishInstance.java +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncPublishInstance.java @@ -1,12 +1,30 @@ -package com.webank.eventmesh.client.http.demo; -import com.webank.eventmesh.client.http.conf.LiteClientConfig; -import com.webank.eventmesh.client.http.producer.LiteProducer; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.LiteMessage; -import com.webank.eventmesh.common.ThreadUtil; +/* + * Licensed 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.demo; + import org.apache.commons.lang3.RandomStringUtils; 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.ThreadUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,7 +35,7 @@ public class AsyncPublishInstance { public static void main(String[] args) throws Exception { LiteProducer liteProducer = null; - try{ + try { // String eventMeshIPPort = args[0]; String eventMeshIPPort = ""; // final String topic = args[1]; @@ -38,7 +56,7 @@ public static void main(String[] args) throws Exception { liteProducer = new LiteProducer(eventMeshClientConfig); liteProducer.start(); - for(int i = 0; i < 1; i++) { + for (int i = 0; i < 1; i++) { LiteMessage liteMessage = new LiteMessage(); liteMessage.setBizSeqNo(RandomStringUtils.randomNumeric(30)) // .setContent("contentStr with special protocal") @@ -51,16 +69,16 @@ public static void main(String[] args) throws Exception { Thread.sleep(1000); logger.info("publish result , {}", flag); } - }catch (Exception e){ + } catch (Exception e) { logger.warn("publish msg failed", e); } - try{ + try { Thread.sleep(30000); - if(liteProducer != null){ + if (liteProducer != null) { liteProducer.shutdown(); } - }catch (Exception e1){ + } catch (Exception e1) { logger.warn("producer shutdown exception", e1); } } diff --git a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/http/demo/AsyncSyncRequestInstance.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncSyncRequestInstance.java similarity index 65% rename from eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/http/demo/AsyncSyncRequestInstance.java rename to eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncSyncRequestInstance.java index c61cfd7096..a03618595e 100644 --- a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/http/demo/AsyncSyncRequestInstance.java +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncSyncRequestInstance.java @@ -1,12 +1,31 @@ -package com.webank.eventmesh.client.http.demo; -import com.webank.eventmesh.client.http.conf.LiteClientConfig; -import com.webank.eventmesh.client.http.producer.LiteProducer; -import com.webank.eventmesh.client.http.producer.RRCallback; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.LiteMessage; -import com.webank.eventmesh.common.ThreadUtil; +/* + * Licensed 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.demo; + + import org.apache.commons.lang3.RandomStringUtils; 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.ThreadUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,12 +81,12 @@ public void onException(Throwable e) { logger.warn("async send msg failed", e); } - try{ + try { Thread.sleep(30000); - if(liteProducer != null){ + if (liteProducer != null) { liteProducer.shutdown(); } - }catch (Exception e1){ + } catch (Exception e1) { logger.warn("producer shutdown exception", e1); } } diff --git a/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/SyncRequestInstance.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/SyncRequestInstance.java similarity index 63% rename from eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/SyncRequestInstance.java rename to eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/SyncRequestInstance.java index 9be5cad16b..22e3f40a61 100644 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/SyncRequestInstance.java +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/SyncRequestInstance.java @@ -1,11 +1,29 @@ -package com.webank.eventmesh.http.demo; -import com.webank.eventmesh.client.http.conf.LiteClientConfig; -import com.webank.eventmesh.client.http.producer.LiteProducer; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.LiteMessage; -import com.webank.eventmesh.common.ThreadUtil; +/* + * Licensed 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.demo; + import org.apache.commons.lang3.RandomStringUtils; 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.ThreadUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,12 +71,12 @@ public static void main(String[] args) throws Exception { logger.warn("send msg failed", e); } - try{ + try { Thread.sleep(30000); - if(liteProducer != null){ + if (liteProducer != null) { liteProducer.shutdown(); } - }catch (Exception e1){ + } catch (Exception e1) { logger.warn("producer shutdown exception", e1); } } diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/common/EventMeshTestCaseTopicSet.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/common/EventMeshTestCaseTopicSet.java new file mode 100644 index 0000000000..171b3d9e10 --- /dev/null +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/common/EventMeshTestCaseTopicSet.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.client.tcp.common; + +/** + * Testcase set + */ +public class EventMeshTestCaseTopicSet { + + // public static final String TOPIC_PRX_WQ2ClientBroadCast = "topic-broadcast-test"; + public static final String TOPIC_PRX_WQ2ClientBroadCast = "FT0-e-80030001-01-3"; + + // public static final String TOPIC_PRX_SyncSubscribeTest = "topic-sync-test"; + public static final String TOPIC_PRX_SyncSubscribeTest = "FT0-s-80000000-01-0"; + + // public static final String TOPIC_PRX_WQ2ClientUniCast = "topic-async-test"; + public static final String TOPIC_PRX_WQ2ClientUniCast = "FT0-e-80010000-01-1"; + +} diff --git a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/common/EventMeshTestUtils.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/common/EventMeshTestUtils.java similarity index 74% rename from eventmesh-test/src/main/java/com/webank/eventmesh/tcp/common/EventMeshTestUtils.java rename to eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/common/EventMeshTestUtils.java index b413fbc471..a34f523788 100644 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/common/EventMeshTestUtils.java +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/common/EventMeshTestUtils.java @@ -1,12 +1,38 @@ -package com.webank.eventmesh.tcp.common; - -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.*; +/* + * Licensed 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 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 com.webank.eventmesh.tcp.common.EventMeshTestCaseTopicSet.*; -import static com.webank.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 static org.apache.eventmesh.common.protocol.tcp.Command.RESPONSE_TO_SERVER; + + + public class EventMeshTestUtils { private static final int seqLength = 10; diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncPublish.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncPublish.java new file mode 100644 index 0000000000..4768127176 --- /dev/null +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncPublish.java @@ -0,0 +1,59 @@ +/* + * Licensed 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 AsyncPublish { + + public static Logger logger = LoggerFactory.getLogger(AsyncPublish.class); + + private static EventMeshClient client; + + public static AsyncPublish handler = new AsyncPublish(); + + 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(); + + 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); + + Thread.sleep(1000); + } + + Thread.sleep(2000); + //退出,销毁资源 +// client.close(); + } catch (Exception e) { + logger.warn("AsyncPublish failed", e); + } + } +} 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 new file mode 100644 index 0000000000..a4d527fc12 --- /dev/null +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncPublishBroadcast.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.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); + //退出,销毁资源 +// 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 new file mode 100644 index 0000000000..319e428772 --- /dev/null +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncSubscribe.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.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.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("FT0-e-80010000-01-1"); + client.registerSubBusiHandler(handler); + + client.listen(); + + //client.unsubscribe(); + + //退出,销毁资源 +// 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 new file mode 100644 index 0000000000..8b77e1a3a9 --- /dev/null +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/AsyncSubscribeBroadcast.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.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.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("FT0-e-80030001-01-3"); + client.registerSubBusiHandler(handler); + + client.listen(); + + //client.unsubscribe(); + + //退出,销毁资源 +// 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 new file mode 100644 index 0000000000..c4c14f5c0d --- /dev/null +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/SyncRequest.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.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); + + //退出,销毁资源 +// 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 new file mode 100644 index 0000000000..b4fbbf71af --- /dev/null +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/tcp/demo/SyncResponse.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.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.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("FT0-s-80000000-01-0"); + //同步RR消息 + client.registerSubBusiHandler(handler); + + client.listen(); + + //client.unsubscribe(); + + //退出,销毁资源 +// 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/resources/application.properties b/eventmesh-sdk-java/src/test/resources/application.properties index 2338e474b6..8bc9ce9a40 100644 --- a/eventmesh-sdk-java/src/test/resources/application.properties +++ b/eventmesh-sdk-java/src/test/resources/application.properties @@ -1 +1,17 @@ +# +# Licensed 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. +# server.port=8088 \ No newline at end of file diff --git a/eventmesh-sdk-java/src/test/resources/log4j2.xml b/eventmesh-sdk-java/src/test/resources/log4j2.xml index 99f79985fb..4297021f90 100644 --- a/eventmesh-sdk-java/src/test/resources/log4j2.xml +++ b/eventmesh-sdk-java/src/test/resources/log4j2.xml @@ -28,7 +28,7 @@ - + diff --git a/eventmesh-starter/build.gradle b/eventmesh-starter/build.gradle index 71fad83d98..7b81c6bf08 100644 --- a/eventmesh-starter/build.gradle +++ b/eventmesh-starter/build.gradle @@ -1,14 +1,22 @@ -plugins { - id 'java' -} - -sourceCompatibility = 1.8 - -repositories { - mavenCentral() -} +/* + * Licensed 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 { - compile project(":eventmesh-runtime"), project(":eventmesh-connector-rocketmq") - testCompile group: 'junit', name: 'junit', version: '4.12' + implementation project(":eventmesh-runtime"), project(":eventmesh-connector-rocketmq") + testImplementation project(":eventmesh-runtime"), project(":eventmesh-connector-rocketmq") + //testImplementation group: 'junit', name: 'junit', version: '4.12' } \ No newline at end of file diff --git a/eventmesh-starter/gradle.properties b/eventmesh-starter/gradle.properties index b0d1e599ec..60d084498a 100644 --- a/eventmesh-starter/gradle.properties +++ b/eventmesh-starter/gradle.properties @@ -14,9 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # - -group=com.webank.eventmesh +group=org.apache.eventmesh version=1.2.0-SNAPSHOT -defibus_version=1.0.1 mavenUserName= mavenPassword= diff --git a/eventmesh-starter/src/main/java/com/webank/eventmesh/starter/StartUp.java b/eventmesh-starter/src/main/java/com/webank/eventmesh/starter/StartUp.java deleted file mode 100644 index 3771f27b21..0000000000 --- a/eventmesh-starter/src/main/java/com/webank/eventmesh/starter/StartUp.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.webank.eventmesh.starter; - -import com.webank.eventmesh.runtime.boot.EventMeshStartup; - -public class StartUp { - public static void main(String[] args) throws Exception { - EventMeshStartup.main(args); - } -} diff --git a/eventmesh-starter/src/main/java/org/apache/eventmesh/starter/StartUp.java b/eventmesh-starter/src/main/java/org/apache/eventmesh/starter/StartUp.java new file mode 100644 index 0000000000..4a2ab9d5ac --- /dev/null +++ b/eventmesh-starter/src/main/java/org/apache/eventmesh/starter/StartUp.java @@ -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. + */ + +package org.apache.eventmesh.starter; + +import org.apache.eventmesh.runtime.boot.EventMeshStartup; + +public class StartUp { + public static void main(String[] args) throws Exception { + EventMeshStartup.main(args); + } +} diff --git a/eventmesh-test/bin/http_pub.sh b/eventmesh-test/bin/http_pub.sh index b6f07f7826..5c34d0bc31 100644 --- a/eventmesh-test/bin/http_pub.sh +++ b/eventmesh-test/bin/http_pub.sh @@ -1,18 +1,21 @@ #!/bin/sh - - -# Copyright (C) @2017 Webank Group Holding Limited -# -# 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 +# 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 # -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. #=========================================================================================== # Java Environment Setting @@ -43,13 +46,13 @@ function get_pid { else if [[ $OS =~ Msys ]]; then # 在Msys上存在可能无法kill识别出的进程的BUG - ppid=`jps -v | grep -i "com.webank.eventmesh.http.demo.AsyncPublishInstance" | grep java | grep -v grep | awk -F ' ' {'print $1'}` + ppid=`jps -v | grep -i "org.apache.eventmesh.http.demo.AsyncPublishInstance" | grep java | grep -v grep | awk -F ' ' {'print $1'}` elif [[ $OS =~ Darwin ]]; then # 已知问题:grep java 可能无法精确识别java进程 - ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "com.webank.eventmesh.http.demo.AsyncPublishInstance" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "org.apache.eventmesh.http.demo.AsyncPublishInstance" | grep -Ev "^root" |awk -F ' ' {'print $2'}) else #在Linux服务器上要求尽可能精确识别进程 - ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_HOME | grep -i "com.webank.eventmesh.http.demo.AsyncPublishInstance" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_HOME | grep -i "org.apache.eventmesh.http.demo.AsyncPublishInstance" | grep -Ev "^root" |awk -F ' ' {'print $2'}) fi fi echo "$ppid"; @@ -124,7 +127,7 @@ make_logs_dir echo "using jdk[$JAVA]" >> ${DEMO_LOG_HOME}/demo_http_pub.out -DEMO_MAIN=com.webank.eventmesh.http.demo.AsyncPublishInstance +DEMO_MAIN=org.apache.eventmesh.http.demo.AsyncPublishInstance if [ $DOCKER ] then $JAVA $JAVA_OPT -classpath ${DEMO_HOME}/conf:${DEMO_HOME}/apps/*:${DEMO_HOME}/lib/* $DEMO_MAIN >> ${DEMO_LOG_HOME}/demo_http_pub.out diff --git a/eventmesh-test/bin/http_sub.sh b/eventmesh-test/bin/http_sub.sh index 67a61e8d86..f5413ca64d 100644 --- a/eventmesh-test/bin/http_sub.sh +++ b/eventmesh-test/bin/http_sub.sh @@ -1,18 +1,21 @@ #!/bin/sh - - -# Copyright (C) @2017 Webank Group Holding Limited -# -# 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 +# 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 # -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. #=========================================================================================== # Java Environment Setting @@ -43,13 +46,13 @@ function get_pid { else if [[ $OS =~ Msys ]]; then # 在Msys上存在可能无法kill识别出的进程的BUG - ppid=`jps -v | grep -i "com.webank.eventmesh.http.demo.sub.SpringBootDemoApplication" | grep java | grep -v grep | awk -F ' ' {'print $1'}` + ppid=`jps -v | grep -i "org.apache.eventmesh.http.demo.sub.SpringBootDemoApplication" | grep java | grep -v grep | awk -F ' ' {'print $1'}` elif [[ $OS =~ Darwin ]]; then # 已知问题:grep java 可能无法精确识别java进程 - ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "com.webank.eventmesh.http.demo.sub.SpringBootDemoApplication" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "org.apache.eventmesh.http.demo.sub.SpringBootDemoApplication" | grep -Ev "^root" |awk -F ' ' {'print $2'}) else #在Linux服务器上要求尽可能精确识别进程 - ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_HOME | grep -i "com.webank.eventmesh.http.demo.sub.SpringBootDemoApplication" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_HOME | grep -i "org.apache.eventmesh.http.demo.sub.SpringBootDemoApplication" | grep -Ev "^root" |awk -F ' ' {'print $2'}) fi fi echo "$ppid"; @@ -124,7 +127,7 @@ make_logs_dir echo "using jdk[$JAVA]" >> ${DEMO_LOG_HOME}/demo_http_sub.out -DEMO_MAIN=com.webank.eventmesh.http.demo.sub.SpringBootDemoApplication +DEMO_MAIN=org.apache.eventmesh.http.demo.sub.SpringBootDemoApplication if [ $DOCKER ] then $JAVA $JAVA_OPT -classpath ${DEMO_HOME}/conf:${DEMO_HOME}/apps/*:${DEMO_HOME}/lib/* $DEMO_MAIN >> ${DEMO_LOG_HOME}/demo_http_sub.out diff --git a/eventmesh-test/bin/tcp_pub.sh b/eventmesh-test/bin/tcp_pub.sh index 71b03dc1e5..fcf7c51214 100644 --- a/eventmesh-test/bin/tcp_pub.sh +++ b/eventmesh-test/bin/tcp_pub.sh @@ -1,18 +1,21 @@ #!/bin/sh - - -# Copyright (C) @2017 Webank Group Holding Limited -# -# 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 +# 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 # -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. #=========================================================================================== # Java Environment Setting @@ -43,13 +46,13 @@ function get_pid { else if [[ $OS =~ Msys ]]; then # 在Msys上存在可能无法kill识别出的进程的BUG - ppid=`jps -v | grep -i "com.webank.eventmesh.tcp.demo.AsyncPublish" | grep java | grep -v grep | awk -F ' ' {'print $1'}` + ppid=`jps -v | grep -i "org.apache.eventmesh.tcp.demo.AsyncPublish" | grep java | grep -v grep | awk -F ' ' {'print $1'}` elif [[ $OS =~ Darwin ]]; then # 已知问题:grep java 可能无法精确识别java进程 - ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "com.webank.eventmesh.tcp.demo.AsyncPublish" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "org.apache.eventmesh.tcp.demo.AsyncPublish" | grep -Ev "^root" |awk -F ' ' {'print $2'}) else #在Linux服务器上要求尽可能精确识别进程 - ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_HOME | grep -i "com.webank.eventmesh.tcp.demo.AsyncPublish" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_HOME | grep -i "org.apache.eventmesh.tcp.demo.AsyncPublish" | grep -Ev "^root" |awk -F ' ' {'print $2'}) fi fi echo "ppid"; @@ -124,7 +127,7 @@ make_logs_dir echo "using jdk[$JAVA]" >> ${DEMO_LOG_HOME}/demo_tcp_pub.out -DEMO_MAIN=com.webank.eventmesh.tcp.demo.AsyncPublish +DEMO_MAIN=org.apache.eventmesh.tcp.demo.AsyncPublish if [ $DOCKER ] then $JAVA $JAVA_OPT -classpath ${DEMO_HOME}/conf:${DEMO_HOME}/apps/*:${DEMO_HOME}/lib/* $DEMO_MAIN >> ${DEMO_LOG_HOME}/demo_tcp_pub.out diff --git a/eventmesh-test/bin/tcp_pub_broadcast.sh b/eventmesh-test/bin/tcp_pub_broadcast.sh index 3bcb18d1b4..25f2bc5619 100644 --- a/eventmesh-test/bin/tcp_pub_broadcast.sh +++ b/eventmesh-test/bin/tcp_pub_broadcast.sh @@ -1,18 +1,21 @@ #!/bin/sh - - -# Copyright (C) @2017 Webank Group Holding Limited -# -# 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 +# 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 # -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. #=========================================================================================== # Java Environment Setting @@ -43,13 +46,13 @@ function get_pid { else if [[ $OS =~ Msys ]]; then # 在Msys上存在可能无法kill识别出的进程的BUG - ppid=`jps -v | grep -i "com.webank.eventmesh.tcp.demo.AsyncPublishBroadcast" | grep java | grep -v grep | awk -F ' ' {'print $1'}` + ppid=`jps -v | grep -i "org.apache.eventmesh.tcp.demo.AsyncPublishBroadcast" | grep java | grep -v grep | awk -F ' ' {'print $1'}` elif [[ $OS =~ Darwin ]]; then # 已知问题:grep java 可能无法精确识别java进程 - ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "com.webank.eventmesh.tcp.demo.AsyncPublishBroadcast" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "org.apache.eventmesh.tcp.demo.AsyncPublishBroadcast" | grep -Ev "^root" |awk -F ' ' {'print $2'}) else #在Linux服务器上要求尽可能精确识别进程 - ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $DEMO_HOME | grep -i "com.webank.eventmesh.tcp.demo.AsyncPublishBroadcast" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $DEMO_HOME | grep -i "org.apache.eventmesh.tcp.demo.AsyncPublishBroadcast" | grep -Ev "^root" |awk -F ' ' {'print $2'}) fi fi echo "$ppid"; @@ -124,7 +127,7 @@ make_logs_dir echo "using jdk[$JAVA]" >> ${DEMO_LOG_HOME}/demo_tcp_pub_broadcast.out -DEMO_MAIN=com.webank.eventmesh.tcp.demo.AsyncPublishBroadcast +DEMO_MAIN=org.apache.eventmesh.tcp.demo.AsyncPublishBroadcast if [ $DOCKER ] then $JAVA $JAVA_OPT -classpath ${DEMO_HOME}/conf:${DEMO_HOME}/apps/*:${DEMO_HOME}/lib/* $DEMO_MAIN >> ${DEMO_LOG_HOME}/demo_tcp_pub_broadcast.out diff --git a/eventmesh-test/bin/tcp_sub.sh b/eventmesh-test/bin/tcp_sub.sh index 77f3aeb090..5a1a572cac 100644 --- a/eventmesh-test/bin/tcp_sub.sh +++ b/eventmesh-test/bin/tcp_sub.sh @@ -1,18 +1,21 @@ #!/bin/sh - - -# Copyright (C) @2017 Webank Group Holding Limited -# -# 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 +# 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 # -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. #=========================================================================================== # Java Environment Setting @@ -43,13 +46,13 @@ function get_pid { else if [[ $OS =~ Msys ]]; then # 在Msys上存在可能无法kill识别出的进程的BUG - ppid=`jps -v | grep -i "com.webank.eventmesh.tcp.demo.AsyncSubscribe" | grep java | grep -v grep | awk -F ' ' {'print $1'}` + ppid=`jps -v | grep -i "org.apache.eventmesh.tcp.demo.AsyncSubscribe" | grep java | grep -v grep | awk -F ' ' {'print $1'}` elif [[ $OS =~ Darwin ]]; then # 已知问题:grep java 可能无法精确识别java进程 - ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "com.webank.eventmesh.tcp.demo.AsyncSubscribe" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "org.apache.eventmesh.tcp.demo.AsyncSubscribe" | grep -Ev "^root" |awk -F ' ' {'print $2'}) else #在Linux服务器上要求尽可能精确识别进程 - ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $DEMO_HOME | grep -i "com.webank.eventmesh.tcp.demo.AsyncSubscribe" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $DEMO_HOME | grep -i "org.apache.eventmesh.tcp.demo.AsyncSubscribe" | grep -Ev "^root" |awk -F ' ' {'print $2'}) fi fi echo "$ppid"; @@ -124,7 +127,7 @@ make_logs_dir echo "using jdk[$JAVA]" >> ${DEMO_LOG_HOME}/demo_tcp_sub.out -DEMO_MAIN=com.webank.eventmesh.tcp.demo.AsyncSubscribe +DEMO_MAIN=org.apache.eventmesh.tcp.demo.AsyncSubscribe if [ $DOCKER ] then $JAVA $JAVA_OPT -classpath ${DEMO_HOME}/conf:${DEMO_HOME}/apps/*:${DEMO_HOME}/lib/* $DEMO_MAIN >> ${DEMO_LOG_HOME}/demo_tcp_sub.out diff --git a/eventmesh-test/bin/tcp_sub_broadcast.sh b/eventmesh-test/bin/tcp_sub_broadcast.sh index 41fbde6a4f..472f711b7d 100644 --- a/eventmesh-test/bin/tcp_sub_broadcast.sh +++ b/eventmesh-test/bin/tcp_sub_broadcast.sh @@ -1,18 +1,21 @@ #!/bin/sh - - -# Copyright (C) @2017 Webank Group Holding Limited -# -# 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 +# 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 # -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. #=========================================================================================== # Java Environment Setting @@ -43,13 +46,13 @@ function get_pid { else if [[ $OS =~ Msys ]]; then # 在Msys上存在可能无法kill识别出的进程的BUG - ppid=`jps -v | grep -i "com.webank.eventmesh.tcp.demo.AsyncSubscribeBroadcast" | grep java | grep -v grep | awk -F ' ' {'print $1'}` + ppid=`jps -v | grep -i "org.apache.eventmesh.tcp.demo.AsyncSubscribeBroadcast" | grep java | grep -v grep | awk -F ' ' {'print $1'}` elif [[ $OS =~ Darwin ]]; then # 已知问题:grep java 可能无法精确识别java进程 - ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "com.webank.eventmesh.tcp.demo.AsyncSubscribeBroadcast" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "org.apache.eventmesh.tcp.demo.AsyncSubscribeBroadcast" | grep -Ev "^root" |awk -F ' ' {'print $2'}) else #在Linux服务器上要求尽可能精确识别进程 - ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_HOME | grep -i "com.webank.eventmesh.tcp.demo.AsyncSubscribeBroadcast" | grep -Ev "^root" |awk -F ' ' {'print $2'}) + ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_HOME | grep -i "org.apache.eventmesh.tcp.demo.AsyncSubscribeBroadcast" | grep -Ev "^root" |awk -F ' ' {'print $2'}) fi fi echo "$ppid"; @@ -124,7 +127,7 @@ make_logs_dir echo "using jdk[$JAVA]" >> ${DEMO_LOG_HOME}/demo_tcp_sub_broadcast.out -DEMO_MAIN=com.webank.eventmesh.tcp.demo.AsyncSubscribeBroadcast +DEMO_MAIN=org.apache.eventmesh.tcp.demo.AsyncSubscribeBroadcast if [ $DOCKER ] then $JAVA $JAVA_OPT -classpath ${DEMO_HOME}/conf:${DEMO_HOME}/apps/*:${DEMO_HOME}/lib/* $DEMO_MAIN >> ${DEMO_LOG_HOME}/demo_tcp_sub_broadcast.out diff --git a/eventmesh-test/build.gradle b/eventmesh-test/build.gradle index 5e90bad522..d433a5bbad 100644 --- a/eventmesh-test/build.gradle +++ b/eventmesh-test/build.gradle @@ -1,81 +1,50 @@ -buildscript { - repositories { - // 优先使用国内源 - maven { url 'https://maven.aliyun.com/repository/public' } - mavenCentral() - } -// dependencies { -// // 让spring-boot支持gradle -// classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE") -// } -} - -//apply plugin: 'org.springframework.boot' -//apply plugin: "io.spring.dependency-management" -apply plugin: 'java' -apply plugin: "maven" -apply plugin: "eclipse" -apply plugin: "idea" - -group 'com.webank.eventmesh' -version '1.2.0-SNAPSHOT' +/* + * Licensed 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. + */ + + +//group 'org.apache.eventmesh' +//version '1.2.0-SNAPSHOT' -sourceCompatibility = 1.8 - -repositories { - mavenCentral() -} - -List apache_common = [ - "org.apache.commons:commons-text:1.9" -] List spring_framework = [ "org.springframework.boot:spring-boot-starter-web:2.1.6.RELEASE" ] -List junit = [ - "junit:junit:4.12" -] - -//List log4j2 = [ -// "org.apache.logging.log4j:log4j-api:2.13.3", -// "org.apache.logging.log4j:log4j-core:2.13.3", -// "org.apache.logging.log4j:log4j-slf4j-impl:2.13.3", -// "org.apache.logging.log4j:log4j-web:2.13.3", -// "com.lmax:disruptor:3.4.2" -//] -// -//List sl4j = [ -// "org.slf4j:slf4j-api:1.7.30" -//] - dependencies { // compile log4j2, sl4j // testCompile log4j2, sl4j - compile project(":eventmesh-sdk-java"),spring_framework,apache_common + implementation project(":eventmesh-sdk-java"),project(":eventmesh-connector-api"),project(":eventmesh-common"),spring_framework //Spring模块 - testCompile junit,apache_common + testImplementation project(":eventmesh-sdk-java"),project(":eventmesh-connector-api"),project(":eventmesh-common"),spring_framework } -configurations.all{ +configurations.all { exclude group: "ch.qos.logback" exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' } -clean.doFirst { - delete 'build' - delete 'dist' -} - task testdist(dependsOn: ['jar']) { - doFirst { - 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() + 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() } doLast { diff --git a/eventmesh-test/conf/application.properties b/eventmesh-test/conf/application.properties index 2886a8c218..8289cb6b01 100644 --- a/eventmesh-test/conf/application.properties +++ b/eventmesh-test/conf/application.properties @@ -1,3 +1,19 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# server.port=8088 eventmesh.ip=127.0.0.1 eventmesh.http.port=10105 diff --git a/eventmesh-test/conf/log4j2.xml b/eventmesh-test/conf/log4j2.xml index 1483ca35fd..87bd36cde3 100644 --- a/eventmesh-test/conf/log4j2.xml +++ b/eventmesh-test/conf/log4j2.xml @@ -28,7 +28,7 @@ - + diff --git a/eventmesh-test/conf/server.env b/eventmesh-test/conf/server.env index 77e68cefeb..3bef8c5fcf 100644 --- a/eventmesh-test/conf/server.env +++ b/eventmesh-test/conf/server.env @@ -1 +1,17 @@ +# +# Licensed 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. +# APP_START_JVM_OPTION:::-server -Xms64M -Xmx128M -Xmn64m -XX:SurvivorRatio=4 -Duser.language=zh diff --git a/eventmesh-test/gradle.properties b/eventmesh-test/gradle.properties index e7cdcc01d2..60d084498a 100644 --- a/eventmesh-test/gradle.properties +++ b/eventmesh-test/gradle.properties @@ -14,8 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # - -group=com.webank.eventmesh +group=org.apache.eventmesh version=1.2.0-SNAPSHOT mavenUserName= mavenPassword= diff --git a/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/sub/SpringBootDemoApplication.java b/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/sub/SpringBootDemoApplication.java deleted file mode 100644 index e8edbfb38e..0000000000 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/sub/SpringBootDemoApplication.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.webank.eventmesh.http.demo.sub; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; - -@SpringBootApplication -@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}) -public class SpringBootDemoApplication { - - public static void main(String[] args) { - SpringApplication.run(SpringBootDemoApplication.class, args); - } -} diff --git a/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/sub/controller/SubController.java b/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/sub/controller/SubController.java deleted file mode 100644 index b268b8b5c7..0000000000 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/sub/controller/SubController.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.webank.eventmesh.http.demo.sub.controller; - -import com.alibaba.fastjson.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -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; - - -@RestController -@RequestMapping("/sub") -public class SubController { - - public static Logger logger = LoggerFactory.getLogger(SubController.class); - - @RequestMapping(value = "/test", method = RequestMethod.POST) - public String subTest(@RequestBody String message){ - logger.info("=======receive message======= {}", JSONObject.toJSONString(message)); - JSONObject result = new JSONObject(); - result.put("retCode", 1); - return result.toJSONString(); - } - -} diff --git a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/common/EventMeshTestCaseTopicSet.java b/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/common/EventMeshTestCaseTopicSet.java deleted file mode 100644 index 4f2fa832a2..0000000000 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/common/EventMeshTestCaseTopicSet.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.webank.eventmesh.tcp.common; - -/** - * Testcase set - */ -public class EventMeshTestCaseTopicSet { - -// public static final String TOPIC_PRX_WQ2ClientBroadCast = "topic-broadcast-test"; - public static final String TOPIC_PRX_WQ2ClientBroadCast = "FT0-e-80030000-01-3"; - -// public static final String TOPIC_PRX_SyncSubscribeTest = "topic-sync-test"; - public static final String TOPIC_PRX_SyncSubscribeTest = "FT0-s-80000000-01-0"; - -// public static final String TOPIC_PRX_WQ2ClientUniCast = "topic-async-test"; - public static final String TOPIC_PRX_WQ2ClientUniCast = "FT0-e-80010000-01-1"; - -} diff --git a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/AsyncPublish.java b/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/AsyncPublish.java deleted file mode 100644 index 74ac50d167..0000000000 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/AsyncPublish.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.webank.eventmesh.tcp.demo; - -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.EventMeshCommon; -import com.webank.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import com.webank.eventmesh.tcp.common.EventMeshTestUtils; -import com.webank.eventmesh.util.Utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Properties; - -public class AsyncPublish{ - - public static Logger logger = LoggerFactory.getLogger(AsyncPublish.class); - - private static EventMeshClient 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(eventMeshIp,eventMeshTcpPort,userAgent); - 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); - - Thread.sleep(1000); - } - - Thread.sleep(2000); - //退出,销毁资源 -// client.close(); - }catch (Exception e){ - logger.warn("AsyncPublish failed", e); - } - } -} diff --git a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/AsyncPublishBroadcast.java b/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/AsyncPublishBroadcast.java deleted file mode 100644 index ad142424ae..0000000000 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/AsyncPublishBroadcast.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.webank.eventmesh.tcp.demo; - -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.EventMeshCommon; -import com.webank.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import com.webank.eventmesh.tcp.common.EventMeshTestUtils; -import com.webank.eventmesh.util.Utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Properties; - -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); - 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); - //退出,销毁资源 -// client.close(); - }catch (Exception e){ - logger.warn("AsyncPublishBroadcast failed", e); - } - } -} diff --git a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/AsyncSubscribe.java b/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/AsyncSubscribe.java deleted file mode 100644 index d84cfd3389..0000000000 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/AsyncSubscribe.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.webank.eventmesh.tcp.demo; - -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.ReceiveMsgHook; -import com.webank.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import com.webank.eventmesh.tcp.common.EventMeshTestUtils; -import com.webank.eventmesh.util.Utils; -import io.netty.channel.ChannelHandlerContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Properties; - -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{ - 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); - client.init(); - client.heartbeat(); - - client.subscribe("FT0-e-80010000-01-1"); - client.registerSubBusiHandler(handler); - - client.listen(); - - //client.unsubscribe(); - - //退出,销毁资源 -// 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-test/src/main/java/com/webank/eventmesh/tcp/demo/AsyncSubscribeBroadcast.java b/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/AsyncSubscribeBroadcast.java deleted file mode 100644 index 731842cb33..0000000000 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/AsyncSubscribeBroadcast.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.webank.eventmesh.tcp.demo; - -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.ReceiveMsgHook; -import com.webank.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import com.webank.eventmesh.tcp.common.EventMeshTestUtils; -import com.webank.eventmesh.util.Utils; -import io.netty.channel.ChannelHandlerContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Properties; - -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{ - 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); - client.init(); - client.heartbeat(); - - client.subscribe("FT0-e-80030000-01-3"); - client.registerSubBusiHandler(handler); - - client.listen(); - - //client.unsubscribe(); - - //退出,销毁资源 -// 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-test/src/main/java/com/webank/eventmesh/tcp/demo/SyncRequest.java b/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/SyncRequest.java deleted file mode 100644 index b4bb47cebd..0000000000 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/SyncRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.webank.eventmesh.tcp.demo; - -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.EventMeshCommon; -import com.webank.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import com.webank.eventmesh.tcp.common.EventMeshTestUtils; -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); - - //退出,销毁资源 -// client.close(); - }catch (Exception e){ - logger.warn("SyncRequest failed", e); - } - } -} diff --git a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/SyncResponse.java b/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/SyncResponse.java deleted file mode 100644 index acd8776a36..0000000000 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/tcp/demo/SyncResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.webank.eventmesh.tcp.demo; - -import com.webank.eventmesh.client.tcp.EventMeshClient; -import com.webank.eventmesh.client.tcp.common.ReceiveMsgHook; -import com.webank.eventmesh.client.tcp.impl.DefaultEventMeshClient; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; -import com.webank.eventmesh.tcp.common.EventMeshTestUtils; -import io.netty.channel.ChannelHandlerContext; -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("FT0-s-80000000-01-0"); - //同步RR消息 - client.registerSubBusiHandler(handler); - - client.listen(); - - //client.unsubscribe(); - - //退出,销毁资源 -// 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-test/src/main/java/com/webank/eventmesh/http/demo/AsyncPublishInstance.java b/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/AsyncPublishInstance.java similarity index 64% rename from eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/AsyncPublishInstance.java rename to eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/AsyncPublishInstance.java index 14b3ee35f4..b718bcc2e0 100644 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/AsyncPublishInstance.java +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/AsyncPublishInstance.java @@ -1,18 +1,36 @@ -package com.webank.eventmesh.http.demo; -import com.webank.eventmesh.client.http.conf.LiteClientConfig; -import com.webank.eventmesh.client.http.producer.LiteProducer; -import com.webank.eventmesh.common.Constants; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.LiteMessage; -import com.webank.eventmesh.common.ThreadUtil; -import com.webank.eventmesh.util.Utils; +/* + * Licensed 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.RandomStringUtils; 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.ThreadUtil; +import org.apache.eventmesh.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Properties; - public class AsyncPublishInstance { public static Logger logger = LoggerFactory.getLogger(AsyncPublishInstance.class); @@ -23,7 +41,7 @@ public static void main(String[] args) throws Exception { final String eventMeshHttpPort = properties.getProperty("eventmesh.http.port"); LiteProducer liteProducer = null; - try{ + try { // String eventMeshIPPort = args[0]; String eventMeshIPPort = eventMeshIp + ":" + eventMeshHttpPort; // final String topic = args[1]; @@ -44,7 +62,7 @@ public static void main(String[] args) throws Exception { liteProducer = new LiteProducer(eventMeshClientConfig); liteProducer.start(); - for(int i = 0; i < 5; i++) { + for (int i = 0; i < 5; i++) { LiteMessage liteMessage = new LiteMessage(); liteMessage.setBizSeqNo(RandomStringUtils.randomNumeric(30)) // .setContent("contentStr with special protocal") @@ -57,16 +75,16 @@ public static void main(String[] args) throws Exception { Thread.sleep(1000); logger.info("publish result , {}", flag); } - }catch (Exception e){ + } catch (Exception e) { logger.warn("publish msg failed", e); } - try{ + try { Thread.sleep(30000); - if(liteProducer != null){ + if (liteProducer != null) { liteProducer.shutdown(); } - }catch (Exception e1){ + } catch (Exception e1) { logger.warn("producer shutdown exception", e1); } } diff --git a/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/AsyncSyncRequestInstance.java b/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/AsyncSyncRequestInstance.java similarity index 67% rename from eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/AsyncSyncRequestInstance.java rename to eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/AsyncSyncRequestInstance.java index b442061dee..54b2f2cbca 100644 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/AsyncSyncRequestInstance.java +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/AsyncSyncRequestInstance.java @@ -1,18 +1,36 @@ -package com.webank.eventmesh.http.demo; -import com.webank.eventmesh.client.http.conf.LiteClientConfig; -import com.webank.eventmesh.client.http.producer.LiteProducer; -import com.webank.eventmesh.client.http.producer.RRCallback; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.LiteMessage; -import com.webank.eventmesh.common.ThreadUtil; -import com.webank.eventmesh.util.Utils; +/* + * Licensed 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.RandomStringUtils; 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.ThreadUtil; +import org.apache.eventmesh.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Properties; - public class AsyncSyncRequestInstance { public static Logger logger = LoggerFactory.getLogger(AsyncSyncRequestInstance.class); @@ -69,12 +87,12 @@ public void onException(Throwable e) { logger.warn("async send msg failed", e); } - try{ + try { Thread.sleep(30000); - if(liteProducer != null){ + if (liteProducer != null) { liteProducer.shutdown(); } - }catch (Exception e1){ + } catch (Exception e1) { logger.warn("producer shutdown exception", e1); } } diff --git a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/http/demo/SyncRequestInstance.java b/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/SyncRequestInstance.java similarity index 63% rename from eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/http/demo/SyncRequestInstance.java rename to eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/SyncRequestInstance.java index 878027b408..239beeadde 100644 --- a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/http/demo/SyncRequestInstance.java +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/SyncRequestInstance.java @@ -1,11 +1,29 @@ -package com.webank.eventmesh.client.http.demo; -import com.webank.eventmesh.client.http.conf.LiteClientConfig; -import com.webank.eventmesh.client.http.producer.LiteProducer; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.LiteMessage; -import com.webank.eventmesh.common.ThreadUtil; +/* + * Licensed 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 org.apache.commons.lang3.RandomStringUtils; 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.ThreadUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,12 +71,12 @@ public static void main(String[] args) throws Exception { logger.warn("send msg failed", e); } - try{ + try { Thread.sleep(30000); - if(liteProducer != null){ + if (liteProducer != null) { liteProducer.shutdown(); } - }catch (Exception e1){ + } catch (Exception e1) { logger.warn("producer shutdown exception", e1); } } diff --git a/eventmesh-runtime/src/test/java/protocol/CmdHelloTest.java b/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/SpringBootDemoApplication.java similarity index 58% rename from eventmesh-runtime/src/test/java/protocol/CmdHelloTest.java rename to eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/SpringBootDemoApplication.java index c472c384bc..931e608a27 100644 --- a/eventmesh-runtime/src/test/java/protocol/CmdHelloTest.java +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/SpringBootDemoApplication.java @@ -15,22 +15,18 @@ * limitations under the License. */ -package protocol; +package org.apache.eventmesh.http.demo.sub; -import client.common.Server; -import org.junit.Test; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -public class CmdHelloTest { +@SpringBootApplication +@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class}) +public class SpringBootDemoApplication { - @Test - public void test_Cmd_Hello() throws Exception { - Server server = new Server(); - server.startAccessServer(); - - //do protocol send/receive - - Thread.sleep(3000); - server.shutdownAccessServer(); + public static void main(String[] args) { + SpringApplication.run(SpringBootDemoApplication.class, args); } - } diff --git a/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/controller/SubController.java b/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/controller/SubController.java new file mode 100644 index 0000000000..8f8a7a7f9b --- /dev/null +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/controller/SubController.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.http.demo.sub.controller; + +import com.alibaba.fastjson.JSONObject; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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; + + +@RestController +@RequestMapping("/sub") +public class SubController { + + public static Logger logger = LoggerFactory.getLogger(SubController.class); + + @RequestMapping(value = "/test", method = RequestMethod.POST) + public String subTest(@RequestBody String message) { + logger.info("=======receive message======= {}", JSONObject.toJSONString(message)); + JSONObject result = new JSONObject(); + result.put("retCode", 1); + return result.toJSONString(); + } + +} diff --git a/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/sub/service/SubService.java b/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/service/SubService.java similarity index 88% rename from eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/sub/service/SubService.java rename to eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/service/SubService.java index a21f31aeed..e20fea98be 100644 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/http/demo/sub/service/SubService.java +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/service/SubService.java @@ -1,21 +1,21 @@ -package com.webank.eventmesh.http.demo.sub.service; +package org.apache.eventmesh.http.demo.sub.service; + +import java.util.Arrays; +import java.util.List; +import java.util.Properties; -import com.webank.eventmesh.client.http.conf.LiteClientConfig; -import com.webank.eventmesh.client.http.consumer.LiteConsumer; -import com.webank.eventmesh.common.IPUtil; -import com.webank.eventmesh.common.EventMeshException; -import com.webank.eventmesh.common.ThreadUtil; -import com.webank.eventmesh.util.Utils; 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.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.stereotype.Component; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; - @Component public class SubService implements InitializingBean { diff --git a/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/common/EventMeshTestCaseTopicSet.java b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/common/EventMeshTestCaseTopicSet.java new file mode 100644 index 0000000000..e229c85184 --- /dev/null +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/common/EventMeshTestCaseTopicSet.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.tcp.common; + +/** + * Testcase set + */ +public class EventMeshTestCaseTopicSet { + + // public static final String TOPIC_PRX_WQ2ClientBroadCast = "topic-broadcast-test"; + public static final String TOPIC_PRX_WQ2ClientBroadCast = "FT0-e-80030000-01-3"; + + // public static final String TOPIC_PRX_SyncSubscribeTest = "topic-sync-test"; + public static final String TOPIC_PRX_SyncSubscribeTest = "FT0-s-80000000-01-0"; + + // public static final String TOPIC_PRX_WQ2ClientUniCast = "topic-async-test"; + public static final String TOPIC_PRX_WQ2ClientUniCast = "FT0-e-80010000-01-1"; + +} diff --git a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/common/EventMeshTestUtils.java b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/common/EventMeshTestUtils.java similarity index 75% rename from eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/common/EventMeshTestUtils.java rename to eventmesh-test/src/main/java/org/apache/eventmesh/tcp/common/EventMeshTestUtils.java index a2ae673e10..dedce3a05b 100644 --- a/eventmesh-sdk-java/src/test/java/com/webank/eventmesh/client/tcp/common/EventMeshTestUtils.java +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/common/EventMeshTestUtils.java @@ -1,15 +1,34 @@ -package com.webank.eventmesh.client.tcp.common; - -import com.webank.eventmesh.common.protocol.tcp.EventMeshMessage; -import com.webank.eventmesh.common.protocol.tcp.Command; -import com.webank.eventmesh.common.protocol.tcp.Header; -import com.webank.eventmesh.common.protocol.tcp.Package; -import com.webank.eventmesh.common.protocol.tcp.UserAgent; +/* + * Licensed 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.common; + +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 static com.webank.eventmesh.client.tcp.common.EventMeshTestCaseTopicSet.*; -import static com.webank.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.Package; +import org.apache.eventmesh.common.protocol.tcp.UserAgent; public class EventMeshTestUtils { private static final int seqLength = 10; diff --git a/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/AsyncPublish.java b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/AsyncPublish.java new file mode 100644 index 0000000000..73cc045c64 --- /dev/null +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/AsyncPublish.java @@ -0,0 +1,66 @@ +/* + * Licensed 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 java.util.Properties; + +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.util.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AsyncPublish { + + public static Logger logger = LoggerFactory.getLogger(AsyncPublish.class); + + private static EventMeshClient 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(eventMeshIp, eventMeshTcpPort, userAgent); + 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); + + Thread.sleep(1000); + } + + Thread.sleep(2000); + //退出,销毁资源 +// client.close(); + } catch (Exception e) { + logger.warn("AsyncPublish failed", e); + } + } +} diff --git a/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/AsyncPublishBroadcast.java b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/AsyncPublishBroadcast.java new file mode 100644 index 0000000000..923c04a90b --- /dev/null +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/AsyncPublishBroadcast.java @@ -0,0 +1,59 @@ +/* + * Licensed 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 java.util.Properties; + +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.util.Utils; +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 { + 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); + 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); + //退出,销毁资源 +// client.close(); + } catch (Exception e) { + logger.warn("AsyncPublishBroadcast failed", e); + } + } +} diff --git a/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/AsyncSubscribe.java b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/AsyncSubscribe.java new file mode 100644 index 0000000000..1f7d3c89b3 --- /dev/null +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/AsyncSubscribe.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.tcp.demo; + +import java.util.Properties; + +import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.client.tcp.EventMeshClient; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; +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 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 { + 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); + client.init(); + client.heartbeat(); + + client.subscribe("FT0-e-80010000-01-1"); + client.registerSubBusiHandler(handler); + + client.listen(); + + //client.unsubscribe(); + + //退出,销毁资源 +// 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-test/src/main/java/org/apache/eventmesh/tcp/demo/AsyncSubscribeBroadcast.java b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/AsyncSubscribeBroadcast.java new file mode 100644 index 0000000000..74bdaaa212 --- /dev/null +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/AsyncSubscribeBroadcast.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.tcp.demo; + +import java.util.Properties; + +import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.client.tcp.EventMeshClient; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +import org.apache.eventmesh.client.tcp.impl.DefaultEventMeshClient; +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 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 { + 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); + client.init(); + client.heartbeat(); + + client.subscribe("FT0-e-80030000-01-3"); + client.registerSubBusiHandler(handler); + + client.listen(); + + //client.unsubscribe(); + + //退出,销毁资源 +// 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-test/src/main/java/org/apache/eventmesh/tcp/demo/SyncRequest.java b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/SyncRequest.java new file mode 100644 index 0000000000..d25f29dfbb --- /dev/null +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/SyncRequest.java @@ -0,0 +1,55 @@ +/* + * Licensed 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); + + //退出,销毁资源 +// client.close(); + } catch (Exception e) { + logger.warn("SyncRequest failed", e); + } + } +} diff --git a/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/SyncResponse.java b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/SyncResponse.java new file mode 100644 index 0000000000..969163d44b --- /dev/null +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/tcp/demo/SyncResponse.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.tcp.demo; + +import io.netty.channel.ChannelHandlerContext; + +import org.apache.eventmesh.client.tcp.EventMeshClient; +import org.apache.eventmesh.client.tcp.common.ReceiveMsgHook; +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.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("FT0-s-80000000-01-0"); + //同步RR消息 + client.registerSubBusiHandler(handler); + + client.listen(); + + //client.unsubscribe(); + + //退出,销毁资源 +// 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-test/src/main/java/com/webank/eventmesh/util/Utils.java b/eventmesh-test/src/main/java/org/apache/eventmesh/util/Utils.java similarity index 74% rename from eventmesh-test/src/main/java/com/webank/eventmesh/util/Utils.java rename to eventmesh-test/src/main/java/org/apache/eventmesh/util/Utils.java index 1e4450ede1..c20b91b6e5 100644 --- a/eventmesh-test/src/main/java/com/webank/eventmesh/util/Utils.java +++ b/eventmesh-test/src/main/java/org/apache/eventmesh/util/Utils.java @@ -1,8 +1,21 @@ -package com.webank.eventmesh.util; +/* + * Licensed 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. + */ -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.core.io.support.PropertiesLoaderUtils; +package org.apache.eventmesh.util; import java.net.InetAddress; import java.net.NetworkInterface; @@ -11,6 +24,10 @@ 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 { /** @@ -50,11 +67,11 @@ public static boolean isWindowsOS() { private static String getLinuxLocalIp() throws SocketException { String ip = ""; try { - for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { + for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) { 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(); diff --git a/gradle.properties b/gradle.properties index 795561d41e..34542ec282 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,11 +14,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # -group=com.webank.eventmesh -version=1.2.0-SNAPSHOT -rocketmqVersion=4.4.0 jdk=1.8 snapshot=false -mavenUserName= -mavenPassword= -#org.gradle.java.home=C:\\Program Files\\Java\\jdk1.7.0_67 +group=org.apache.eventmesh +version=1.2.0-SNAPSHOT +#last eight bits of public key +signing.keyId= +#passphrase for key pairs +signing.password= +#path of exporting private key +signing.secretKeyRingFile= +#apache id +apacheUserName= +#apache password +apachePassWord= +signEnabled=false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 442d9132ea..1ad74a57e2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,21 @@ +# +# Licensed 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. +# distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/package.json b/package.json deleted file mode 100644 index 77057b3165..0000000000 --- a/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "zqq", - "version": "1.0.0", - "description": "[![Build Status](https://www.travis-ci.org/WeBankFinTech/DeFiBus.svg?branch=master)](https://www.travis-ci.org/WeBankFinTech/EventMesh) [![Coverage Status](https://coveralls.io/repos/github/WeBankFinTech/DeFiBus/badge.svg?branch=master)](https://coveralls.io/github/WeBankFinTech/EventMesh?branch=master) [![GitHub release](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/WeBankFinTech/EventMesh/releases) [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)", - "main": "index.js", - "directories": { - "doc": "docs" - }, - "scripts": { - "docs:dev": "vuepress dev docs", - "docs:build": "vuepress build docs" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "vuepress": "^1.7.1" - } -} diff --git a/settings.gradle b/settings.gradle index b7f436b771..ea31ffdc16 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,11 +17,5 @@ rootProject.name = 'EventMesh' String jdkVersion = "${jdk}" -include 'eventmesh-runtime' -include 'eventmesh-connector-rocketmq' -include 'eventmesh-sdk-java' -include 'eventmesh-common' -include 'eventmesh-connector-api' -include 'eventmesh-starter' -include 'eventmesh-test' +include 'eventmesh-runtime','eventmesh-connector-rocketmq','eventmesh-sdk-java','eventmesh-common','eventmesh-connector-api','eventmesh-starter','eventmesh-test' diff --git a/style/codeStyle.xml b/style/codeStyle.xml index 9b4e561f9c..6b60186f16 100644 --- a/style/codeStyle.xml +++ b/style/codeStyle.xml @@ -15,7 +15,7 @@ ~ limitations under the License. --> - +