|
|
@ -339,19 +339,18 @@ public class ResourcesService extends BaseService { |
|
|
|
String resourcePath = ""; |
|
|
|
String resourcePath = ""; |
|
|
|
if (type.equals(ResourceType.FILE)) { |
|
|
|
if (type.equals(ResourceType.FILE)) { |
|
|
|
hdfsFilename = HadoopUtils.getHdfsFilename(tenantCode, name); |
|
|
|
hdfsFilename = HadoopUtils.getHdfsFilename(tenantCode, name); |
|
|
|
resourcePath = HadoopUtils.getHdfsDir(tenantCode); |
|
|
|
resourcePath = HadoopUtils.getHdfsResDir(tenantCode); |
|
|
|
} else if (type.equals(ResourceType.UDF)) { |
|
|
|
} else if (type.equals(ResourceType.UDF)) { |
|
|
|
hdfsFilename = HadoopUtils.getHdfsUdfFilename(tenantCode, name); |
|
|
|
hdfsFilename = HadoopUtils.getHdfsUdfFilename(tenantCode, name); |
|
|
|
resourcePath = HadoopUtils.getHdfsUdfDir(tenantCode); |
|
|
|
resourcePath = HadoopUtils.getHdfsUdfDir(tenantCode); |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (HadoopUtils.getInstance().exists(resourcePath)) { |
|
|
|
// if tenant dir not exists
|
|
|
|
|
|
|
|
if (!HadoopUtils.getInstance().exists(resourcePath)) { |
|
|
|
|
|
|
|
createTenantDirIfNotExists(tenantCode); |
|
|
|
|
|
|
|
} |
|
|
|
cn.escheduler.api.utils.FileUtils.copyFile(file, localFilename); |
|
|
|
cn.escheduler.api.utils.FileUtils.copyFile(file, localFilename); |
|
|
|
HadoopUtils.getInstance().copyLocalToHdfs(localFilename, hdfsFilename, true, true); |
|
|
|
HadoopUtils.getInstance().copyLocalToHdfs(localFilename, hdfsFilename, true, true); |
|
|
|
} else { |
|
|
|
|
|
|
|
logger.error("{} is not exist", resourcePath); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage(), e); |
|
|
|
logger.error(e.getMessage(), e); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -678,22 +677,19 @@ public class ResourcesService extends BaseService { |
|
|
|
|
|
|
|
|
|
|
|
// get file hdfs path
|
|
|
|
// get file hdfs path
|
|
|
|
hdfsFileName = HadoopUtils.getHdfsFilename(tenantCode, resourceName); |
|
|
|
hdfsFileName = HadoopUtils.getHdfsFilename(tenantCode, resourceName); |
|
|
|
String resourcePath = HadoopUtils.getHdfsDir(tenantCode); |
|
|
|
String resourcePath = HadoopUtils.getHdfsResDir(tenantCode); |
|
|
|
logger.info("resource hdfs path is {} ", hdfsFileName); |
|
|
|
logger.info("resource hdfs path is {} ", hdfsFileName); |
|
|
|
|
|
|
|
|
|
|
|
HadoopUtils hadoopUtils = HadoopUtils.getInstance(); |
|
|
|
HadoopUtils hadoopUtils = HadoopUtils.getInstance(); |
|
|
|
if (hadoopUtils.exists(resourcePath)) { |
|
|
|
if (!hadoopUtils.exists(resourcePath)) { |
|
|
|
|
|
|
|
// create if tenant dir not exists
|
|
|
|
|
|
|
|
createTenantDirIfNotExists(tenantCode); |
|
|
|
|
|
|
|
} |
|
|
|
if (hadoopUtils.exists(hdfsFileName)) { |
|
|
|
if (hadoopUtils.exists(hdfsFileName)) { |
|
|
|
hadoopUtils.delete(hdfsFileName, false); |
|
|
|
hadoopUtils.delete(hdfsFileName, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
hadoopUtils.copyLocalToHdfs(localFilename, hdfsFileName, true, true); |
|
|
|
hadoopUtils.copyLocalToHdfs(localFilename, hdfsFileName, true, true); |
|
|
|
} else { |
|
|
|
|
|
|
|
logger.error("{} is not exist", resourcePath); |
|
|
|
|
|
|
|
result.setCode(Status.HDFS_OPERATION_ERROR.getCode()); |
|
|
|
|
|
|
|
result.setMsg(String.format("%s is not exist", resourcePath)); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage(), e); |
|
|
|
logger.error(e.getMessage(), e); |
|
|
|
result.setCode(Status.HDFS_OPERATION_ERROR.getCode()); |
|
|
|
result.setCode(Status.HDFS_OPERATION_ERROR.getCode()); |
|
|
|