Skip to content
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 @@ -210,10 +210,7 @@ class EngineExecutionContext(executor: ComputationExecutor, executorUser: String
}
}
if (!AccessibleExecutorConfiguration.ENGINECONN_SUPPORT_PARALLELISM.getValue) {
val taskLogs = taskLog.split("\n")
taskLogs.foreach(line => {
LogHelper.cacheLog(line)
})
LogHelper.cacheLog(taskLog)
} else {
val listenerBus = getEngineSyncListenerBus
getJobId.foreach(jId => listenerBus.postToAll(TaskLogUpdateEvent(jId, taskLog)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1445,17 +1445,18 @@ public Message pythonUpload(
value = "path",
example = "file:///test-dir/test-sub-dir/test1012_01.py")
@RequestMapping(path = "/get-register-functions", method = RequestMethod.GET)
public Message getRegisterFunctions(HttpServletRequest req, @RequestParam("path") String path) {
public Message getRegisterFunctions(HttpServletRequest req, @RequestParam("path") String path) throws IOException {
if (StringUtils.endsWithIgnoreCase(path, Constants.FILE_EXTENSION_PY)
|| StringUtils.endsWithIgnoreCase(path, Constants.FILE_EXTENSION_SCALA)) {
if (StringUtils.startsWithIgnoreCase(path, StorageUtils$.MODULE$.FILE_SCHEMA())) {
FileSystem fileSystem = null;
try {
// 获取登录用户
String userName = ModuleUserUtils.getOperationUser(req, "get-register-functions");

FsPath fsPath = new FsPath(path);
// 获取文件系统实例
FileSystem fileSystem = (FileSystem) FSFactory.getFsByProxyUser(fsPath, userName);
fileSystem = (FileSystem) FSFactory.getFsByProxyUser(fsPath, userName);
fileSystem.init(null);
if (fileSystem.canRead(fsPath)) {
return Message.ok()
Expand All @@ -1465,6 +1466,10 @@ public Message getRegisterFunctions(HttpServletRequest req, @RequestParam("path"
}
} catch (Exception e) {
return Message.error("解析文件失败,错误信息:" + e);
} finally {
if (fileSystem != null) {
fileSystem.close();
}
}
} else {
return Message.error("仅支持本地文件");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,20 @@ public static List<String> extractDependencies(String content, String name) {

public static List<String> getRegisterFunctions(FileSystem fileSystem, FsPath fsPath, String path)
throws Exception {
try (InputStream is = fileSystem.read(fsPath)) {
// 将inputstream内容转换为字符串
String content = IOUtils.toString(is, StandardCharsets.UTF_8);
if (StringUtils.endsWith(path, Constants.FILE_EXTENSION_PY)) {
// 解析python文件
return extractPythonMethodNames(path);
} else if (StringUtils.endsWith(path, Constants.FILE_EXTENSION_SCALA)) {
if (StringUtils.endsWith(path, Constants.FILE_EXTENSION_PY)) {
// 解析python文件
return extractPythonMethodNames(path);
} else if (StringUtils.endsWith(path, Constants.FILE_EXTENSION_SCALA)) {
try (InputStream is = fileSystem.read(fsPath)) {
// 将inputstream内容转换为字符串
String content = IOUtils.toString(is, StandardCharsets.UTF_8);
// 解析scala代码
return extractScalaMethodNames(content);
} else {
throw new UdfException(80041, "Unsupported file type: " + path);
} catch (IOException e) {
throw new UdfException(80042, "Failed to read file: " + path, e);
}
} catch (IOException e) {
throw new UdfException(80042, "Failed to read file: " + path, e);
} else {
throw new UdfException(80041, "Unsupported file type: " + path);
}
}

Expand Down
Loading