| | |
| | | } |
| | | catch (RuntimeException exception) |
| | | { |
| | | // 单行配置有问题(例如缺少口令环境变量)不得拦住后端启动: |
| | | // 记下原因,由发现轮询按周期重试并把失败持久化到这一行。 |
| | | // 单行配置有问题(例如没放凭据文件、口令键名写错)不得拦住后端启动: |
| | | // 既写日志,也按发现失败的同一路径落到这一行,使"忘了配"在启动后立刻是列表里可见的一行。 |
| | | log.warn("设备适配器实例装配失败 adapterCode={}:{}", adapter.getAdapterCode(), exception.getMessage()); |
| | | mapper.updateDiscoveryFailure(adapter.getAdapterId(), startupFailureCode(exception), |
| | | exception.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 装配失败写进实例行的错误码:适配器自己给出分类(例如凭据缺失、连接失败)时用它, |
| | | * 否则记为配置问题——启动阶段的装配失败基本都是配置造成的。 |
| | | */ |
| | | private static String startupFailureCode(RuntimeException exception) |
| | | { |
| | | return exception instanceof DeviceAdapterException deviceFailure && !deviceFailure.failureCode().isBlank() |
| | | ? deviceFailure.failureCode() : "INVALID_CONFIG"; |
| | | } |
| | | |
| | | /** 轮询达到周期的已启用适配器,并持久化失败状态后继续调度。 */ |
| | | @Override |
| | | public void pollDueAdapters() |