Skip to content

Commit

Permalink
fix resource && resource config
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 committed Oct 18, 2023
1 parent d2db3d9 commit 5250277
Show file tree
Hide file tree
Showing 21 changed files with 464 additions and 473 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public Result<Void> uploadFile(Integer pid, String desc, @RequestParam("file") M
@ApiImplicitParam(name = "id", value = "Resource ID", required = true, dataType = "Integer", paramType = "query")
@SaCheckPermission(PermissionConstants.REGISTRATION_RESOURCE_DELETE)
public Result<Void> remove(Integer id) {
resourcesService.remove(id);
return Result.succeed();
return resourcesService.remove(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public class ResourcesDTO implements Serializable {
notes = "The name of the resource file")
private String fileName;

@ApiModelProperty(
value = "Parent ID",
dataType = "Integer",
example = "1",
notes = "The unique identifier of the parent resource")
private Integer pid;

@ApiModelProperty(
value = "Description",
dataType = "String",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public interface ResourcesService extends IService<Resources> {
*/
void uploadFile(Integer pid, String desc, MultipartFile file);

void remove(Integer id);
Result<Void> remove(Integer id);

/**
* 递归获取所有的资源,从pid到0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.dinky.service.resource.impl;

import org.dinky.data.dto.TreeNodeDTO;
import org.dinky.data.enums.Status;
import org.dinky.data.exception.BusException;
import org.dinky.data.model.Resources;
import org.dinky.data.result.Result;
Expand Down Expand Up @@ -203,27 +204,32 @@ public void uploadFile(Integer pid, String desc, MultipartFile file) {

@Transactional(rollbackFor = Exception.class)
@Override
public void remove(Integer id) {
public Result<Void> remove(Integer id) {
if (id == -1) {
return Result.failed(Status.ROOT_DIR_NOT_ALLOW_DELETE);
}
if (id < 1) {
getBaseResourceManager().remove("/");
// todo 删除主目录,实际是清空
remove(new LambdaQueryWrapper<Resources>().ne(Resources::getId, 0));
return;
return remove(new LambdaQueryWrapper<Resources>().ne(Resources::getId, 0))
? Result.succeed(Status.DELETE_SUCCESS)
: Result.failed(Status.DELETE_FAILED);
}
Resources byId = getById(id);
if (!isExistsChildren(id)) {
removeById(id);
return;
return removeById(id) ? Result.succeed(Status.DELETE_SUCCESS) : Result.failed(Status.DELETE_FAILED);
}
getBaseResourceManager().remove(byId.getFullName());
if (byId.getIsDirectory()) {
List<Resources> resourceByPidToChildren = getResourceByPidToChildren(new ArrayList<>(), byId.getId());
removeBatchByIds(resourceByPidToChildren);
return removeBatchByIds(resourceByPidToChildren)
? Result.succeed(Status.DELETE_SUCCESS)
: Result.failed(Status.DELETE_FAILED);
}
List<Resources> resourceByPidToParent = getResourceByPidToParent(new ArrayList<>(), byId.getPid());
resourceByPidToParent.forEach(x -> x.setSize(x.getSize() - byId.getSize()));
updateBatchById(resourceByPidToParent);
removeById(id);
return removeById(id) ? Result.succeed(Status.DELETE_SUCCESS) : Result.failed(Status.DELETE_FAILED);
}

private boolean isExistsChildren(Integer id) {
Expand Down
18 changes: 11 additions & 7 deletions dinky-common/src/main/java/org/dinky/data/enums/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public enum Status {
EXECUTE_FAILED(9020, "execute.failed"),
RESTART_SUCCESS(9021, "restart.success"),
RESTART_FAILED(9022, "restart.failed"),
// 已成功停止
STOP_SUCCESS(9023, "stop.success"),
STOP_FAILED(9024, "stop.failed"),
RENAME_SUCCESS(9025, "rename.success"),
Expand Down Expand Up @@ -255,6 +254,11 @@ public enum Status {
ALERT_RULE_JOB_RUN_EXCEPTION(20005, "alert.rule.jobRunException"),
ALERT_RULE_CHECKPOINT_TIMEOUT(20006, "alert.rule.checkpointTimeout"),

/**
* Resource
*/
ROOT_DIR_NOT_ALLOW_DELETE(9031, "root.dir.not.allow.delete"),

/**
* global exception
*/
Expand Down Expand Up @@ -327,12 +331,12 @@ public enum Status {
SYS_METRICS_SETTINGS_FLINK_GATHERTIMING_NOTE(153, "sys.metrics.settings.flink.gatherTiming.note"),
SYS_METRICS_SETTINGS_FLINK_GATHERTIMEOUT(154, "sys.metrics.settings.flink.gatherTimeout"),
SYS_METRICS_SETTINGS_FLINK_GATHERTIMEOUT_NOTE(155, "sys.metrics.settings.flink.gatherTimeout.note"),
SYS_RESOURCE_SETTINGS_ENABLE(156, "sys.resource.settings.enable"),
SYS_RESOURCE_SETTINGS_ENABLE_NOTE(157, "sys.resource.settings.enable.note"),
SYS_RESOURCE_SETTINGS_UPLOAD_BASE_PATH(158, "sys.resource.settings.upload.base.path"),
SYS_RESOURCE_SETTINGS_UPLOAD_BASE_PATH_NOTE(159, "sys.resource.settings.upload.base.path.note"),
SYS_RESOURCE_SETTINGS_MODEL(160, "sys.resource.settings.model"),
SYS_RESOURCE_SETTINGS_MODEL_NOTE(161, "sys.resource.settings.model.note"),
SYS_RESOURCE_SETTINGS_ENABLE(156, "sys.resource.settings.base.enable"),
SYS_RESOURCE_SETTINGS_ENABLE_NOTE(157, "sys.resource.settings.base.enable.note"),
SYS_RESOURCE_SETTINGS_UPLOAD_BASE_PATH(158, "sys.resource.settings.base.upload.base.path"),
SYS_RESOURCE_SETTINGS_UPLOAD_BASE_PATH_NOTE(159, "sys.resource.settings.base.upload.base.path.note"),
SYS_RESOURCE_SETTINGS_MODEL(160, "sys.resource.settings.base.model"),
SYS_RESOURCE_SETTINGS_MODEL_NOTE(161, "sys.resource.settings.base.model.note"),
SYS_RESOURCE_SETTINGS_OSS_ENDPOINT(162, "sys.resource.settings.oss.endpoint"),
SYS_RESOURCE_SETTINGS_OSS_ENDPOINT_NOTE(163, "sys.resource.settings.oss.endpoint.note"),
SYS_RESOURCE_SETTINGS_OSS_ACCESSKEY(164, "sys.resource.settings.oss.accessKey"),
Expand Down
42 changes: 23 additions & 19 deletions dinky-common/src/main/resources/i18n/messages_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ alert.rule.jobRunException=Job Run Exception
alert.rule.checkpointTimeout=Checkpoint Timeout

daemon.task.config.not.exist=the thread task configuration can not be empty
daemon.task.not.support=threaded task types are notsupported
daemon.task.not.support=threaded task types are notsupported\uFF1A


# system config
Expand All @@ -177,21 +177,21 @@ sys.dolphinscheduler.settings.enable.note=Whether to enable DolphinScheduler, th
sys.dolphinscheduler.settings.url=DolphinScheduler address
sys.dolphinscheduler.settings.url.note=The address must be consistent with the address configured in the DolphinScheduler background, eg: http://127.0.0.1:12345/dolphinscheduler
sys.dolphinscheduler.settings.token=DolphinScheduler Token
sys.dolphinscheduler.settings.token.note=DolphinScheduler‘s Token, please create a token in DolphinScheduler’s Security Center->Token Management, and fill in the configuration
sys.dolphinscheduler.settings.token.note=DolphinScheduler\u2018s Token, please create a token in DolphinScheduler\u2019s Security Center->Token Management, and fill in the configuration
sys.dolphinscheduler.settings.projectName=DolphinScheduler project name
sys.dolphinscheduler.settings.projectName.note=The project name specified in DolphinScheduler, case insensitive
sys.ldap.settings.url=ldap address of service
sys.ldap.settings.url.note=ldap address of service,eg:ldap://192.168.111.1:389
sys.ldap.settings.url.note=ldap address of service\uFF0Ceg\uFF1Aldap://192.168.111.1:389
sys.ldap.settings.userDn=Login User name (DN)
sys.ldap.settings.userDn.note=User name for connecting to the ldap service, or the administrator DN
sys.ldap.settings.userPassword=login password
sys.ldap.settings.userPassword.note=Password used to connect to the ldap service
sys.ldap.settings.timeLimit=Connection Timeout
sys.ldap.settings.timeLimit.note=The maximum time to connect to the ldap service is disconnected
sys.ldap.settings.baseDn=BaseDn
sys.ldap.settings.baseDn.note=Dinky will conduct a user search on this base dn,eg:ou=users,dc=dinky,dc=com
sys.ldap.settings.baseDn.note=Dinky will conduct a user search on this base dn,eg\uFF1Aou=users,dc=dinky,dc=com
sys.ldap.settings.filter=User filtering rules
sys.ldap.settings.filter.note=User filtering by using the filter syntax of the ldap,eg
sys.ldap.settings.filter.note=User filtering by using the filter syntax of the ldap\uFF0Ceg
sys.ldap.settings.autoload=User atically map users when logging in
sys.ldap.settings.autoload.note=When turned on, when a user logs in with LDAP, if there is no corresponding Dinky user mapping, the LDAP information is automatically pulled to create a Dinky user mapping to it. If this feature is closed, you will not be able to log in for unimported LDAP users
sys.ldap.settings.defaultTeant=The LDAP imports the default tenant code
Expand All @@ -210,20 +210,20 @@ sys.metrics.settings.flink.gatherTiming=Flink Metrics collection time granularit
sys.metrics.settings.flink.gatherTiming.note=Flink Metrics collection time granularity, scheduled task interval trigger
sys.metrics.settings.flink.gatherTimeout=Flink Metrics collection time granularity, scheduled task interval trigger
sys.metrics.settings.flink.gatherTimeout.note=Flink Metrics collection timeout period, scheduled task interval trigger (this configuration item should be smaller than Flink Metrics collection time granularity)
sys.resource.settings.enable=Whether to enable Resource
sys.resource.settings.enable.note=Enable the resource management function. If you switch the storage mode, you need to turn off this switch. After the relevant configuration is completed, turn it on again.
sys.resource.settings.upload.base.path=The root path of the upload directory
sys.resource.settings.upload.base.path.note=resource store on HDFS/OSS path, resource file will store to this base path, self configuration, please make sure the directory exists on hdfs and have read write permissions. /dinky is recommended
sys.resource.settings.model=Storage mode
sys.resource.settings.model.note=Storage mode
sys.resource.settings.base.enable=Whether to enable Resource
sys.resource.settings.base.enable.note=Enable resource management function. If you switch storage mode, you need to turn off this switch. After the relevant configuration is completed, turn it on again.
sys.resource.settings.base.upload.base.path=Root path of the upload directory
sys.resource.settings.base.upload.base.path.note=Resources are stored on the HDFS/OSS path. Resource files will be stored in this base path. Configure it by yourself. Please ensure that the directory exists on the relevant storage system and has read capabilities. Write permission. recommend
sys.resource.settings.base.model=Storage model
sys.resource.settings.base.model.note=Supports HDFS and OSS, it will take effect after switching the option, and resource files will be migrated at the same time.
sys.resource.settings.oss.endpoint=URL of the object storage service
sys.resource.settings.oss.endpoint.note=The URL of the object storage service, for example: https://oss-cn-hangzhou.aliyuncs.com
sys.resource.settings.oss.accessKey=Access key is like a user ID, which can uniquely identify your account
sys.resource.settings.oss.accessKey.note=Access key is like a user ID, which can uniquely identify your account
sys.resource.settings.oss.secretKey=Secret key is your account password
sys.resource.settings.oss.secretKey.note=Secret key is your account password
sys.resource.settings.oss.bucketName=default bucket name
sys.resource.settings.oss.bucketName.note=default bucket name
sys.resource.settings.oss.endpoint.note=For example: https://oss-cn-hangzhou.aliyuncs.com
sys.resource.settings.oss.accessKey=Access key
sys.resource.settings.oss.accessKey.note=Access key is like a user ID that uniquely identifies your account
sys.resource.settings.oss.secretKey=Secret key
sys.resource.settings.oss.secretKey.note=Secret key is the password of your account
sys.resource.settings.oss.bucketName=Bucket name
sys.resource.settings.oss.bucketName.note=Default bucket name
sys.resource.settings.oss.region=region
sys.resource.settings.oss.region.note=region
sys.resource.settings.hdfs.root.user=HDFS operation user name
Expand All @@ -245,4 +245,8 @@ process.submit.checkSql=Check job
process.submit.execute = execute the job
process.submit.buildConfig=Build configuration information
process.submit.execute.commSql=excute commonSql
process.submit.execute.flinkSql=excute flinkSql
process.submit.execute.flinkSql=excute flinkSql


# resource
root.dir.not.allow.delete=The root directory is not allowed to be deleted
Loading

0 comments on commit 5250277

Please sign in to comment.