diff --git a/src/main/java/neatlogic/framework/exception/server/ServerHostRepeatException.java b/src/main/java/neatlogic/framework/exception/server/ServerHostRepeatException.java new file mode 100644 index 0000000000000000000000000000000000000000..f0e806b623023001886679fd78c7a00327eee66a --- /dev/null +++ b/src/main/java/neatlogic/framework/exception/server/ServerHostRepeatException.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.exception.server; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class ServerHostRepeatException extends ApiRuntimeException { + + public ServerHostRepeatException(Integer serverId, String host, Integer currentServerId) { + super("应用服务器{0}的host({1})与应用服务器{2}的host({3})相同", serverId, host, currentServerId, host); + } +} diff --git a/src/main/java/neatlogic/framework/exception/server/ServerStopException.java b/src/main/java/neatlogic/framework/exception/server/ServerStopException.java new file mode 100644 index 0000000000000000000000000000000000000000..d8e66ba1840522b62b315ac1f4381d6cf39ddf09 --- /dev/null +++ b/src/main/java/neatlogic/framework/exception/server/ServerStopException.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.exception.server; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class ServerStopException extends ApiRuntimeException { + + public ServerStopException(Integer serverId, String host) { + super("应用服务器{0}({1})已停机", serverId, host); + } +} diff --git a/src/main/java/neatlogic/framework/integration/core/IntegrationHandlerBase.java b/src/main/java/neatlogic/framework/integration/core/IntegrationHandlerBase.java index a9ad979eb468a381dd2b20a0ad2ec5f26c889301..0708ba01848bc74f162dc3658b507cba42ee4c67 100644 --- a/src/main/java/neatlogic/framework/integration/core/IntegrationHandlerBase.java +++ b/src/main/java/neatlogic/framework/integration/core/IntegrationHandlerBase.java @@ -286,7 +286,7 @@ public abstract class IntegrationHandlerBase implements IIntegrationHandler { connection.connect(); } catch (Exception e) { String errorMsg = e.getMessage() == null ? ExceptionUtils.getStackTrace(e) : e.getMessage(); - logger.error(e.getMessage(), e); + logger.error(url + ", " + e.getMessage(), e); integrationAuditVo.appendError(errorMsg); resultVo.appendError(errorMsg); integrationAuditVo.setStatus("failed"); @@ -302,7 +302,7 @@ public abstract class IntegrationHandlerBase implements IIntegrationHandler { } out.flush(); } catch (Exception e) { - logger.error(e.getMessage(), e); + logger.error(url + ", " + e.getMessage(), e); resultVo.appendError(e.getMessage()); integrationAuditVo.appendError(e.getMessage()); integrationAuditVo.setStatus("failed"); @@ -338,7 +338,7 @@ public abstract class IntegrationHandlerBase implements IIntegrationHandler { throw new RuntimeException(writer.toString()); } } catch (Exception e) { - logger.error(e.getMessage(), e); + logger.error(url + ", " + e.getMessage(), e); resultVo.appendError(e.getMessage()); integrationAuditVo.appendError(e.getMessage()); integrationAuditVo.setStatus("failed"); @@ -355,7 +355,7 @@ public abstract class IntegrationHandlerBase implements IIntegrationHandler { } hasTransferred = true; } catch (Exception ex) { - logger.error(ex.getMessage(), ex); + logger.error(url + ", " + ex.getMessage(), ex); resultVo.appendError(ex.getMessage()); integrationAuditVo.appendError(ex.getMessage()); integrationAuditVo.setStatus("failed"); diff --git a/src/main/java/neatlogic/framework/util/HttpRequestUtil.java b/src/main/java/neatlogic/framework/util/HttpRequestUtil.java index 7029586a7c1fb4e470920b506af32e8fc42854f1..316ac0f56077cdf70ce71d78ec2ecf256bedbfbe 100644 --- a/src/main/java/neatlogic/framework/util/HttpRequestUtil.java +++ b/src/main/java/neatlogic/framework/util/HttpRequestUtil.java @@ -563,7 +563,7 @@ public class HttpRequestUtil { connection.connect(); return connection; } catch (Exception ex) { - logger.error(this.url + "-" + ex.getMessage(), ex); + logger.error(this.url + ", " + ex.getMessage(), ex); this.error = ExceptionUtils.getStackTrace(ex); this.errorMsg = ex.getMessage(); } @@ -638,7 +638,7 @@ public class HttpRequestUtil { } this.errorMsg = message; } catch (Exception e) { - logger.error(e.getMessage(), e); + logger.error(this.url + ", " + e.getMessage(), e); this.error = ExceptionUtils.getStackTrace(e); this.errorMsg = e.getMessage(); } finally { diff --git a/src/main/java/neatlogic/module/framework/service/FileServiceImpl.java b/src/main/java/neatlogic/module/framework/service/FileServiceImpl.java index 36b12fdb16101f85632a62c499c00d7dfb33f30d..54d5d3aeca54682f78c2e0e606e5d3eeaa15f2d2 100644 --- a/src/main/java/neatlogic/module/framework/service/FileServiceImpl.java +++ b/src/main/java/neatlogic/module/framework/service/FileServiceImpl.java @@ -28,7 +28,9 @@ import neatlogic.framework.exception.file.FileNotFoundException; import neatlogic.framework.exception.file.FilePathIllegalException; import neatlogic.framework.exception.file.FileTypeHandlerNotFoundException; import neatlogic.framework.exception.server.ServerHostIsBankException; +import neatlogic.framework.exception.server.ServerHostRepeatException; import neatlogic.framework.exception.server.ServerNotFoundException; +import neatlogic.framework.exception.server.ServerStopException; import neatlogic.framework.exception.user.NoTenantException; import neatlogic.framework.file.core.FileOperationType; import neatlogic.framework.file.core.FileTypeHandlerFactory; @@ -223,6 +225,14 @@ public class FileServiceImpl implements IFileCrossoverService { if (StringUtils.isBlank(host)) { throw new ServerHostIsBankException(serverId); } + if (Objects.equals(serverClusterVo.getStatus(), ServerClusterVo.STOP)) { + throw new ServerStopException(serverClusterVo.getServerId(), serverClusterVo.getHost()); + } + if (Objects.equals(paramObj.getInteger("forwardCount"), 1)) { + throw new ServerHostRepeatException(serverId, host, Config.SCHEDULE_SERVER_ID); + } else { + paramObj.put("forwardCount", 1); + } HttpServletRequest request = RequestContext.get().getRequest(); String url = host + request.getRequestURI(); HttpRequestUtil httpRequestUtil = HttpRequestUtil.post(url)