This is an automated email from the ASF dual-hosted git repository.
dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong-website.git
The following commit(s) were added to refs/heads/master by this push:
new c5b84897bd [INLONG-888][Doc] Update DataProxy JAVA SDK docs (#889)
c5b84897bd is described below
commit c5b84897bd8b525cb98d11a0ef40b194fff47cf9
Author: castor <[email protected]>
AuthorDate: Thu Dec 7 09:32:44 2023 +0800
[INLONG-888][Doc] Update DataProxy JAVA SDK docs (#889)
Co-authored-by: castorqin <[email protected]>
---
docs/sdk/dataproxy-sdk/java.md | 17 +++++++++++++----
.../current/sdk/dataproxy-sdk/java.md | 17 +++++++++++++----
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/docs/sdk/dataproxy-sdk/java.md b/docs/sdk/dataproxy-sdk/java.md
index 38a373a418..7c5eb22c22 100644
--- a/docs/sdk/dataproxy-sdk/java.md
+++ b/docs/sdk/dataproxy-sdk/java.md
@@ -28,12 +28,12 @@ The overall process includes the following three steps:
### Initialize SDK
From the demo code, we can see that the client initialization is mainly done
in the `getMessageSender()` function:
```java
-public DefaultMessageSender getMessageSender(String localIP, String
inLongManagerAddr, String inLongManagerPort, String netTag, String
dataProxyGroup, boolean isLocalVisit, boolean isReadProxyIPFromLocal, String
configBasePath, int msgType) {
+public DefaultMessageSender getMessageSender(String localIP, String
inLongManagerAddr, String inLongManagerPort, String inlongGroupId, boolean
isLocalVisit, boolean isReadProxyIPFromLocal, String configBasePath, int
msgType) {
ProxyClientConfig dataProxyConfig = null;
DefaultMessageSender messageSender = null;
try {
// Initialize client configuration. 'test', '123456' is username and
password, which need to be replaced according to the environment configuration
in actual use.
- dataProxyConfig = new ProxyClientConfig(localIP, isLocalVisit,
inLongManagerAddr, Integer.valueOf(inLongManagerPort), dataProxyGroup, netTag,
"test", "123456");
+ dataProxyConfig = new ProxyClientConfig(localIP, isLocalVisit,
inLongManagerAddr, Integer.valueOf(inLongManagerPort), inlongGroupId, "test",
"123456");
// Set the local save path of the configuration. This setting is
optional. By default, the SDK will create a "/.inlong/" directory under the
current user's working directory to store the configuration.
if (StringUtils.isNotEmpty(configBasePath)) {
dataProxyConfig.setConfStoreBasePath(configBasePath);
@@ -51,6 +51,15 @@ public DefaultMessageSender getMessageSender(String localIP,
String inLongManage
return messageSender;
}
```
+### ProxyClientConfig configuration
+| parameter name | Parameter Description | default value |
+| ------ | ------ | -------|
+| inlongGroupId | inlongGroupId | not null |
+| inlongStreamId | inlongStreamId | not null |
+| username | username | not null|
+| password | password | not null|
+|isLocalVisit| request inlong manager protocol | https: false , http: true|
+|isReadProxyIPFromLocal|whether to read DataProxy ip from local|false|
### Call the send interface to report data
The SDK data send interface is thread safe, support send single or multiple
messages by sync and async two ways. The following demo uses a single sync way
to send, and the message does not contain property information:
@@ -73,8 +82,8 @@ You can also choose different send interfaces to report data
according to your b
### Close SDK
In Demo, there is no close operation. When in use, we can call the `close()`
function of the MessageSender interface object to stop data reporting.
-# Warning
-- The `MessageSender` interface object is initialized based on the GroupID, so
each `MessageSender` object can be used differently based on the GroupID, and
multiple `MessageSender` objects can be created in the same process.
+## Warning
+- The `MessageSender` interface object is initialized based on the
`inlongGroupId`, so each `MessageSender` object can be used differently based
on the `inlongGroupId`, and multiple `MessageSender` objects can be created in
the same process.
- The SDK provides three different network interaction ways: TCP, HTTP, and
UDP. Examples of these three ways are given in the
[example](https://github.com/apache/inlong/blob/master/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example)
(refer to `TcpClientExample.java`, `HttpClientExample.java`,
`UdpClientExample.java`), and the business can be customized according to its
own needs to initialize different `MessageSender` object.
- The SDK contains complex network interactions, `MessageSender` should be
used as a resident object. Avoid frequent initialization and shutdown of
`MessageSender` (frequent initialization and shutdown will have a large
resource overhead and will affect the timeliness of data reporting).
- The SDK does not resend the failed message. When using the SDK to report
data, if send fails, you need to decide whether to resend according to your own
needs.
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sdk/dataproxy-sdk/java.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sdk/dataproxy-sdk/java.md
index 82b17a0184..c6eea285d6 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sdk/dataproxy-sdk/java.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sdk/dataproxy-sdk/java.md
@@ -28,12 +28,12 @@ import {siteVariables} from '../../version';
### 初始化 SDK
从Demo示例代码我们可以看到,客户端初始化主要是在 `getMessageSender()` 函数中完成:
```java
-public DefaultMessageSender getMessageSender(String localIP, String
inLongManagerAddr, String inLongManagerPort, String netTag, String
dataProxyGroup, boolean isLocalVisit, boolean isReadProxyIPFromLocal, String
configBasePath, int msgType) {
+public DefaultMessageSender getMessageSender(String localIP, String
inLongManagerAddr, String inLongManagerPort, String inlongGroupId, boolean
isLocalVisit, boolean isReadProxyIPFromLocal, String configBasePath, int
msgType) {
ProxyClientConfig dataProxyConfig = null;
DefaultMessageSender messageSender = null;
try {
// 初始化客户端配置,其中“test”,“123456”是需要认证的用户名和密码,实际使用时需要根据环境配置进行更替
- dataProxyConfig = new ProxyClientConfig(localIP, isLocalVisit,
inLongManagerAddr, Integer.valueOf(inLongManagerPort), dataProxyGroup, netTag,
"test", "123456");
+ dataProxyConfig = new ProxyClientConfig(localIP, isLocalVisit,
inLongManagerAddr, Integer.valueOf(inLongManagerPort), inlongGroupId, "test",
"123456");
// 设置配置信息的本地保存路径,该设置可选,缺省情况下 SDK
会在当前用户工作目录下构造一个"/.inlong/"目录存储配置数据
if (StringUtils.isNotEmpty(configBasePath)) {
dataProxyConfig.setConfStoreBasePath(configBasePath);
@@ -51,6 +51,15 @@ public DefaultMessageSender getMessageSender(String localIP,
String inLongManage
return messageSender;
}
```
+### 配置参数
+| 参数名 | 参数说明 | 默认值 |
+| ------ | ------ | -------|
+| inlongGroupId | inlongGroupId | not null |
+| inlongStreamId | inlongStreamId | not null |
+| username | 用户名 |not null|
+| password | 密码 |not null|
+| isLocalVisit| 请求inlong Manager协议 |https: false , http: true|
+|isReadProxyIPFromLocal|是否从本地读取 DataProxy Ip|false|
### 调用发送接口进行数据上报
SDK 的数据发送接口时线程安全的,支持以同步或者异步模式发送单条或多条消息。Demo里采用的是单条同步消息发送,并且消息中不包含属性信息:
@@ -73,8 +82,8 @@ public void sendTcpMessage(DefaultMessageSender sender,
String inlongGroupId, St
### 关闭 SDK
Demo 里没有实现关闭操作,使用时我们需要调用MessageSender接口对象的close()函数关闭数据上报服务:
-# 注意事项
--
MessageSender接口对象是基于GroupID进行初始化,因而每个MessageSender对象基于GroupID区别使用,同一个进程内允许创建多个MessageSender对象;
+## 注意事项
+- `MessageSender` 接口对象是基于 `inlongGroupId` 进行初始化,因而每个 `MessageSender` 对象基于
`inlongGroupId` 区别使用,同一个进程内允许创建多个 `MessageSender` 对象;
- SDK
封装了TCP、HTTP、UDP共三种不同的网络交互方式,并在[example](https://github.com/apache/inlong/blob/master/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example)目录里给出了3种方式的不同示例(参考TcpClientExample.java,HttpClientExample.java,UdpClientExample.java实现),业务可以根据自身需要来初始化不同的MessageSender对象;
- SDK 中包含了复杂的网络交互,使用时需要将 SDK
作为常驻服务对象来使用,避免同个进程中途频繁地初始化和关闭MessageSender对象(重复初始化和关闭会带来很大的资源开销,并且影响数据上报的时效性);
- SDK 不对发送失败的消息做重发处理,用户在使用 SDK 上报数据时遇到发送失败,业务要根据自身数据要求来决定是否重发消息,避免数据丢失。