diff --git a/dsms-engine-application/src/main/java/com/dsms/modules/rbd/service/impl/RbdServiceImpl.java b/dsms-engine-application/src/main/java/com/dsms/modules/rbd/service/impl/RbdServiceImpl.java index a9208990e383a97888d1873f963e2c5f70cafb3f..2a93b4698682eeff5adcdc300cf11647713dd9c5 100644 --- a/dsms-engine-application/src/main/java/com/dsms/modules/rbd/service/impl/RbdServiceImpl.java +++ b/dsms-engine-application/src/main/java/com/dsms/modules/rbd/service/impl/RbdServiceImpl.java @@ -16,6 +16,7 @@ package com.dsms.modules.rbd.service.impl; +import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.SecureUtil; import cn.hutool.json.JSONUtil; @@ -73,6 +74,10 @@ public class RbdServiceImpl implements IRbdService { private final IStoragePoolService storagePoolService; private final TaskContext taskContext; + private static final String TASK_ALREADY_EXIST = "Task already exist,task message: {}"; + + private static final String POOL_NOT_AVAILABLE= "pool not available,pool name: {}"; + public RbdServiceImpl(ITaskService taskService, IStoragePoolService storagePoolService, TaskContext taskContext) { this.taskService = taskService; this.storagePoolService = storagePoolService; @@ -175,7 +180,7 @@ public class RbdServiceImpl implements IRbdService { return false; } if (!storagePoolService.isPoolAvailable(rbdCreateDTO.getPoolName())) { - log.error("pool doesn't have any osd"); + log.error(POOL_NOT_AVAILABLE, rbdCreateDTO.getPoolName()); throw new DsmsEngineException(ResultCode.POOL_UNAVAILABLE_ERROR); } @@ -183,7 +188,7 @@ public class RbdServiceImpl implements IRbdService { StoragePool metaPool = storagePoolService.get(rbdCreateDTO.getPoolName()); StoragePool dataPool = metaPool; if (rbdCreateDTO.getBasedOnEra()) { - if (StrUtil.isBlank(rbdCreateDTO.getDataPoolName())) { + if (CharSequenceUtil.isBlank(rbdCreateDTO.getDataPoolName())) { throw DsmsEngineException.exceptionWithMessage("数据池名称不能为空)", ResultCode.RBD_CREATE_TASK_ERROR); } dataPool = storagePoolService.get(rbdCreateDTO.getDataPoolName()); @@ -201,7 +206,7 @@ public class RbdServiceImpl implements IRbdService { String taskMessage = TaskTypeEnum.CREATE_RBD.getName() + ":" + rbdCreateDTO.getRbdName() + ",存储池:" + rbdCreateDTO.getPoolName(); if (!taskContext.validateTask(TaskTypeEnum.CREATE_RBD, taskMessage)) { - log.warn("Task already exist,task message:{}", taskMessage); + log.warn(TASK_ALREADY_EXIST, taskMessage); throw new DsmsEngineException(ResultCode.TASK_EXIST); } Task task = new AsyncTask( @@ -221,13 +226,13 @@ public class RbdServiceImpl implements IRbdService { return false; } if (!storagePoolService.isPoolAvailable(rbdDeleteDTO.getPoolName())) { - log.error("pool doesn't have any osd"); + log.error(POOL_NOT_AVAILABLE, rbdDeleteDTO.getPoolName()); throw new DsmsEngineException(ResultCode.POOL_UNAVAILABLE_ERROR); } String taskMessage = TaskTypeEnum.DELETE_RBD.getName() + ":" + rbdDeleteDTO.getRbdName() + ",存储池:" + rbdDeleteDTO.getPoolName(); if (!taskContext.validateTask(TaskTypeEnum.DELETE_RBD, taskMessage)) { - log.warn("Task already exist,task message:{}", taskMessage); + log.warn(TASK_ALREADY_EXIST, taskMessage); throw new DsmsEngineException(ResultCode.TASK_EXIST); } Task task = new AsyncTask( @@ -247,7 +252,7 @@ public class RbdServiceImpl implements IRbdService { return false; } if (!storagePoolService.isPoolAvailable(rbdUpdateDTO.getPoolName())) { - log.error("pool doesn't have any osd"); + log.error(POOL_NOT_AVAILABLE, rbdUpdateDTO.getPoolName()); throw new DsmsEngineException(ResultCode.POOL_UNAVAILABLE_ERROR); } //The storage volume created based on the erasure code pool needs to calculate the capacity of the data pool @@ -283,7 +288,7 @@ public class RbdServiceImpl implements IRbdService { String taskMessage = TaskTypeEnum.UPDATE_RBD.getName() + ":" + rbdUpdateDTO.getRbdName() + "存储池:" + rbdUpdateDTO.getPoolName() + ",容量:" + rbdUpdateDTO.getRbdSize() + "G"; if (!taskContext.validateTask(TaskTypeEnum.UPDATE_RBD, taskMessage)) { - log.warn("Task already exist,task message:{}", taskMessage); + log.warn(TASK_ALREADY_EXIST, taskMessage); throw new DsmsEngineException(ResultCode.TASK_EXIST); } Task task = new AsyncTask(