Skip to content

[OSPP] Mapper-framework-Java design and implementation#5900

Merged
kubeedge-bot merged 1 commit intokubeedge:feature-multilingual-mapperfrom
ryWangkkk:Mapper-framework-Java
Oct 30, 2024
Merged

[OSPP] Mapper-framework-Java design and implementation#5900
kubeedge-bot merged 1 commit intokubeedge:feature-multilingual-mapperfrom
ryWangkkk:Mapper-framework-Java

Conversation

@ryWangkkk
Copy link
Copy Markdown
Contributor

@ryWangkkk ryWangkkk commented Sep 29, 2024

What type of PR is this?
/kind feature

What this PR does / why we need it:
As other language mapper-frameworks are in demand in actual business, we implement a java version mapper-framework and realize a modbus protocol based mapper as an example. The developers could use the template to customize their own protocol, which could translate information between device and kubeEdge into the format understood by each other.
Which issue(s) this PR fixes:

Fixes #5594

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@kubeedge-bot kubeedge-bot added the kind/design Categorizes issue or PR as related to design. label Sep 29, 2024
@kubeedge-bot kubeedge-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 29, 2024
@ryWangkkk ryWangkkk force-pushed the Mapper-framework-Java branch from d712614 to 72c0f35 Compare September 29, 2024 06:10
@ryWangkkk
Copy link
Copy Markdown
Contributor Author

/assign @kevin-wangzefeng

Copy link
Copy Markdown
Collaborator

@wbc6080 wbc6080 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/kind feature
/remove-kind design
Please describe in detail what this PR is used for in the description of the PR.

@kubeedge-bot kubeedge-bot added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/design Categorizes issue or PR as related to design. labels Sep 29, 2024
@ryWangkkk
Copy link
Copy Markdown
Contributor Author

As other language mapper-frameworks are in demand in actual business, we implement a java version mapper-framework and realize a modbus protocol based mapper as an example. The developers could use the template to customize their own protocol, which could translate information between device and kubeEdge into the format understood by each other.

Copy link
Copy Markdown
Collaborator

@wbc6080 wbc6080 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the go version of mapper-framework, we provide Makefile. Users can execute make generate to generate a custom mapper project, but similar files are not found in the java version. So how to generate a user-defined mapper here?

Comment on lines +1 to +8
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these idea files

Point point = Point.measurement(influxdb2DataConfig.getMeasurement())
.addTags(influxdb2DataConfig.getTag())
.addField(influxdb2DataConfig.getFieldKey(), data.getValue())
.time(Instant.now(), WritePrecision.NS); // 使用纳秒精度
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use English comments

Comment on lines +122 to +124
pstmt.setString(1, dateTime); // 设置日期时间参数
pstmt.setString(2, data.getValue()); // 设置字段值参数
pstmt.executeUpdate(); // 执行插入
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto. Please replace all Chinese comments in the code with English

Copy link
Copy Markdown
Collaborator

@wbc6080 wbc6080 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the check pipeline pass. You can run make verify and then run git status. There will be some new changes and you can push them again.

@wbc6080
Copy link
Copy Markdown
Collaborator

wbc6080 commented Oct 12, 2024

As other language mapper-frameworks are in demand in actual business, we implement a java version mapper-framework and realize a modbus protocol based mapper as an example. The developers could use the template to customize their own protocol, which could translate information between device and kubeEdge into the format understood by each other.

Populate this content into the PR's description
image

@ryWangkkk ryWangkkk changed the title Mapper-framework-Java design and implementation As other language mapper-frameworks are in demand in actual business, we implement a java version mapper-framework and realize a modbus protocol based mapper as an example. The developers could use the template to customize their own protocol, which could translate information between device and kubeEdge into the format understood by each other. Oct 24, 2024
@ryWangkkk
Copy link
Copy Markdown
Contributor Author

As a java project, it makes sense that it wouldn't be able to get past the go pipeline check.
Now we have added Makefile, Dockerfile to help user quickly generate a custom mapper project and build it into a docker image.
Besides that, we have checked all codes and remove Chinese comments or replace it by English.

import driver.CustomizedClient;
import grpc.GrpcClient;
import lombok.Getter;
import lombok.Setter;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether lombok compilation needs to rely on plug-in configuration ? It is recommended to explain it in the readme document.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this project maven is used to manage dependencies, and the pom.xml already contains this dependency

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I compile your project with Idea, don't I need to install the Lombok plugin in Idea?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to install the Lombok plugin in Idea.

private TDEngineClientConfig tdClientConfig;
public Connection initDbClient(){
Connection dbClient = null;
String userName = System.getenv("USERNAME");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

USERNAME and PASSWORD are suggested to be made constants

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to set default values for USERNAME and PASSWORD?
Since USERNAME and PASSWORD are more private information, we want users to enter this information themselves and add it to the local environment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defined as a constant, and here we reference this constant, not a magic string

client.publish(this.mqttpConfig.topic, message);

client.disconnect(250);
System.out.println("############### Message published. ###############");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use System. out. println for logging, as it is usually used for temporary debugging

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will correct it.

//
// File socketFile = new File(socketPath);
// if (socketFile.exists()) {
// if (socketFile.isDirectory()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annotate the code, add comments to explain why, or simply delete them and explain in the readme document

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will correct it.

@wbc6080 wbc6080 changed the title As other language mapper-frameworks are in demand in actual business, we implement a java version mapper-framework and realize a modbus protocol based mapper as an example. The developers could use the template to customize their own protocol, which could translate information between device and kubeEdge into the format understood by each other. Mapper-framework-Java design and implementation Oct 24, 2024
@ryWangkkk ryWangkkk force-pushed the Mapper-framework-Java branch 5 times, most recently from 434dd21 to ce716b5 Compare October 25, 2024 05:22
@ryWangkkk ryWangkkk changed the title Mapper-framework-Java design and implementation [OSSP] Mapper-framework-Java design and implementation Oct 29, 2024
@ryWangkkk ryWangkkk changed the title [OSSP] Mapper-framework-Java design and implementation [OSPP] Mapper-framework-Java design and implementation Oct 29, 2024
@@ -0,0 +1,53 @@
##!/usr/bin/env bash
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this shell is not needed, you can remove this file.

Copy link
Copy Markdown
Collaborator

@wbc6080 wbc6080 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not modify these irrelevant files. @ryWangkkk
image

@ryWangkkk ryWangkkk force-pushed the Mapper-framework-Java branch from f916f2c to 8839729 Compare October 29, 2024 13:24
@kubeedge-bot
Copy link
Copy Markdown
Collaborator

@JiaweiGithub: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ryWangkkk ryWangkkk force-pushed the Mapper-framework-Java branch from 8839729 to 7394e7e Compare October 29, 2024 13:44
@ryWangkkk ryWangkkk force-pushed the Mapper-framework-Java branch from 7394e7e to 376531d Compare October 29, 2024 13:48
// handle /api/v1/ping request
@Override
public void handle(HttpExchange exchange) throws IOException {
// 创建响应对象
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use Chinese comments

private String nameSpace = "";

@JsonProperty("description")
private String description = "";//这个属性暂时没用到
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Signed-off-by: ryWangkkk <ryWang@zju.edu.cn>

Java Version mapper framework

Signed-off-by: ryWangkkk <ryWang@zju.edu.cn>

Java Version mapper framework

Signed-off-by: ryWangkkk <ryWang@zju.edu.cn>

Java Version mapper framework

Signed-off-by: ryWangkkk <ryWang@zju.edu.cn>
@ryWangkkk ryWangkkk force-pushed the Mapper-framework-Java branch from e34cd98 to 8af74fe Compare October 30, 2024 05:06
@Shelley-BaoYue Shelley-BaoYue changed the base branch from master to feature-multilingual-mapper October 30, 2024 08:57
Copy link
Copy Markdown
Collaborator

@wbc6080 wbc6080 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for the first version.

Mappers with other languages ​​are best developed in independent repo, so we firstly merge into the feature development branch and then @ryWangkkk need to migrate to the new repo.

/lgtm
cc @JiaweiGithub @WillardHu @fisherxu

@kubeedge-bot kubeedge-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 30, 2024
Copy link
Copy Markdown
Member

@fisherxu fisherxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@kubeedge-bot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fisherxu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubeedge-bot kubeedge-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 30, 2024
@kubeedge-bot kubeedge-bot merged commit 375ba46 into kubeedge:feature-multilingual-mapper Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[OSPP] Multi-language mapper-framework support

7 participants