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..df069f00cc4df513ba9c7e066d85dc98035818c7 --- /dev/null +++ b/src/main/java/neatlogic/framework/exception/server/ServerHostRepeatException.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2025 TechSure Co., Ltd. All Rights Reserved. + * This file is part of the NeatLogic software. + * Licensed under the NeatLogic Sustainable Use License (NSUL), Version 4.x – 2025. + * You may use this file only in compliance with the License. + * See the LICENSE file distributed with this work for the full license text. + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + */ + +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..725ad079f656139e9b131150de57cf2b42ab704c --- /dev/null +++ b/src/main/java/neatlogic/framework/exception/server/ServerStopException.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2025 TechSure Co., Ltd. All Rights Reserved. + * This file is part of the NeatLogic software. + * Licensed under the NeatLogic Sustainable Use License (NSUL), Version 4.x – 2025. + * You may use this file only in compliance with the License. + * See the LICENSE file distributed with this work for the full license text. + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + */ + +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 3d8a0ae437f41c9d842041a89e699ad6605801c9..da8983d017ecd2d3490d8619f4406dca51f66c47 100644 --- a/src/main/java/neatlogic/framework/integration/core/IntegrationHandlerBase.java +++ b/src/main/java/neatlogic/framework/integration/core/IntegrationHandlerBase.java @@ -299,7 +299,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"); @@ -335,7 +335,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"); @@ -352,7 +352,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 8960b6a2071ee03ec2114bc9eee753bd5b0199cc..4e6ccf5a3d913e9ee3e38340787bbe82f647944a 100644 --- a/src/main/java/neatlogic/framework/util/HttpRequestUtil.java +++ b/src/main/java/neatlogic/framework/util/HttpRequestUtil.java @@ -560,7 +560,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(); } @@ -635,7 +635,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 4428dbfeec4a5f31b117ee2a3d260dbbf5365c0c..1810ec6439aa2f6ad718e6cffea63f041f34343d 100644 --- a/src/main/java/neatlogic/module/framework/service/FileServiceImpl.java +++ b/src/main/java/neatlogic/module/framework/service/FileServiceImpl.java @@ -25,7 +25,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; @@ -220,6 +222,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)