Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for load parameter #272

Merged
merged 3 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ public FileMapping deleteEdgeMapping(@PathVariable("id") int id,
*/
@PostMapping("load-parameter")
public void loadParameter(@RequestBody LoadParameter newEntity) {
this.checkLoadParameter(newEntity);
List<FileMapping> mappings = this.service.listAll();
for (FileMapping mapping : mappings) {
LoadParameter oldEntity = mapping.getLoadParameter();
Expand Down Expand Up @@ -341,4 +342,19 @@ private void checkMappingValid(ElementMapping elementMapping,
"load.file-mapping.value.keys-should-in-column-names");
}
}

private void checkLoadParameter(LoadParameter newEntity) {
Ex.check(newEntity.getMaxParseErrors() == Constant.NO_LIMIT ||
newEntity.getMaxParseErrors() > 0,
"load.file-mapping.load-parameter.max-parse-error.illegal");
Ex.check(newEntity.getMaxInsertErrors() == Constant.NO_LIMIT ||
newEntity.getMaxInsertErrors() > 0,
"load.file-mapping.load-parameter.max-insert-error.illegal");
Ex.check(newEntity.getInsertTimeout() > 0,
"load.file-mapping.load-parameter.insert-timeout.illegal");
Ex.check(newEntity.getRetryTimes() > 0,
"load.file-mapping.load-parameter.retry-times.illegal");
Ex.check(newEntity.getRetryInterval() > 0,
"load.file-mapping.load-parameter.retry-interval.illegal");
}
}
5 changes: 5 additions & 0 deletions hubble-be/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ load.file-mapping.vertex.id-fields-should-in-column-names=The all id fields {0}
load.file-mapping.edge.not-exist.label=The edge mapping doesn't exist with label {0}
load.file-mapping.edge.source-fields-cannot-be-empty=The source fields can't be empty
load.file-mapping.edge.target-fields-cannot-be-empty=The target fields can't be empty
load.file-mapping.load-parameter.max-parse-error.illegal=The load parameter 'max-parse-errors' is illegal
load.file-mapping.load-parameter.max-insert-error.illegal=The load parameter 'max-insert-errors' is illegal
load.file-mapping.load-parameter.insert-timeout.illegal=The load parameter 'insert-timeout' is illegal
load.file-mapping.load-parameter.retry-times.illegal=The load parameter 'retry-times' is illegal
load.file-mapping.load-parameter.retry-interval.illegal=The load parameter 'retry-interval' is illegal
load.build-task.failed=Build load task failed

# job manager
Expand Down
5 changes: 5 additions & 0 deletions hubble-be/src/main/resources/i18n/messages_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ load.file-mapping.vertex.id-fields-should-in-column-names=ID 列 {0} 必须都
load.file-mapping.edge.not-exist.label=不存在 label 为 {0} 的边映射
load.file-mapping.edge.source-fields-cannot-be-empty=起点 ID 列不能为空
load.file-mapping.edge.target-fields-cannot-be-empty=终点 ID 列不能为空
load.file-mapping.load-parameter.max-parse-error.illegal=导入参数 允许最大解析错误行数 不合法
load.file-mapping.load-parameter.max-insert-error.illegal=导入参数 允许最大插入错误行数 不合法
load.file-mapping.load-parameter.insert-timeout.illegal=导入参数 插入超时时间/s 不合法
load.file-mapping.load-parameter.retry-times.illegal=导入参数 插入失败重试次数 不合法
load.file-mapping.load-parameter.retry-interval.illegal=导入参数 插入失败重试间隔/s 不合法
load.build-task.failed=构建导入任务失败

# job manager
Expand Down