Search in sources :

Example 6 with BatchResource

use of com.dtstack.taier.dao.domain.BatchResource in project Taier by DTStack.

the class BatchResourceService method deleteResource.

/**
 * 删除资源
 */
public Long deleteResource(Long tenantId, Long resourceId) {
    List<BatchTaskResource> taskResources = this.batchTaskResourceService.getUseableResources(resourceId);
    if (!CollectionUtils.isEmpty(taskResources)) {
        throw new RdosDefineException(ErrorCode.CAN_NOT_DELETE_RESOURCE);
    }
    List<BatchFunctionResource> functionResources = batchFunctionResourceService.listByResourceId(resourceId);
    if (!CollectionUtils.isEmpty(functionResources)) {
        throw new RdosDefineException(ErrorCode.CAN_NOT_DELETE_RESOURCE);
    }
    // 删除资源在hdfs的实际存储文件
    BatchResource resource = getResource(resourceId);
    try {
        HdfsOperator.checkAndDele(HadoopConf.getConfiguration(tenantId), HadoopConf.getHadoopKerberosConf(tenantId), resource.getUrl());
    } catch (Exception e) {
        LOGGER.error("tenantId:{}  resourceId:{} fail delete resource from HDFS", tenantId, resourceId, e);
    }
    // 删除资源记录
    developResourceDao.deleteById(resourceId);
    return resourceId;
}
Also used : BatchTaskResource(com.dtstack.taier.dao.domain.BatchTaskResource) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) BatchFunctionResource(com.dtstack.taier.dao.domain.BatchFunctionResource) BatchResource(com.dtstack.taier.dao.domain.BatchResource) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException)

Example 7 with BatchResource

use of com.dtstack.taier.dao.domain.BatchResource in project Taier by DTStack.

the class BatchResourceService method replaceResource.

/**
 * 替换资源
 */
public void replaceResource(BatchResourceAddDTO batchResourceAddDTO) {
    Long tenantId = batchResourceAddDTO.getTenantId();
    Long resourceId = batchResourceAddDTO.getId();
    BatchResource resourceDb = developResourceDao.getOne(resourceId);
    if (Objects.isNull(resourceDb)) {
        throw new RdosDefineException("替换字段不存在");
    }
    String resourceName = resourceDb.getResourceName();
    String hdfsPath = uploadHDFSFileWithResource(tenantId, resourceName, batchResourceAddDTO.getOriginalFilename(), batchResourceAddDTO.getTmpPath());
    resourceDb.setUrl(hdfsPath);
    resourceDb.setOriginFileName(batchResourceAddDTO.getOriginalFilename());
    resourceDb.setResourceDesc(batchResourceAddDTO.getResourceDesc());
    resourceDb.setGmtModified(Timestamp.valueOf(LocalDateTime.now()));
    developResourceDao.update(resourceDb);
}
Also used : RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) BatchResource(com.dtstack.taier.dao.domain.BatchResource)

Aggregations

BatchResource (com.dtstack.taier.dao.domain.BatchResource)7 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)6 BatchCatalogue (com.dtstack.taier.dao.domain.BatchCatalogue)4 BatchTask (com.dtstack.taier.dao.domain.BatchTask)3 CatalogueVO (com.dtstack.taier.develop.dto.devlop.CatalogueVO)2 ReadWriteLockVO (com.dtstack.taier.develop.dto.devlop.ReadWriteLockVO)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 JSON (com.alibaba.fastjson.JSON)1 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 JSONPath (com.alibaba.fastjson.JSONPath)1 TypeReference (com.alibaba.fastjson.TypeReference)1 ClientCache (com.dtstack.dtcenter.loader.client.ClientCache)1 IClient (com.dtstack.dtcenter.loader.client.IClient)1 IKerberos (com.dtstack.dtcenter.loader.client.IKerberos)1 ColumnMetaDTO (com.dtstack.dtcenter.loader.dto.ColumnMetaDTO)1 SqlQueryDTO (com.dtstack.dtcenter.loader.dto.SqlQueryDTO)1 ISourceDTO (com.dtstack.dtcenter.loader.dto.source.ISourceDTO)1 DataSourceType (com.dtstack.dtcenter.loader.source.DataSourceType)1