From 5243ec1fe1d05a576df2b3bb1e43effc9394aebd Mon Sep 17 00:00:00 2001 From: "junj2.liang" Date: Tue, 9 Aug 2022 15:38:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9F=AD=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E3=80=81=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sunyard/sge/database/SydApi4Database.java | 8 ++++++ src/test/java/test/FuncTest.java | 28 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sunyard/sge/database/SydApi4Database.java b/src/main/java/com/sunyard/sge/database/SydApi4Database.java index 515a517..35f541c 100644 --- a/src/main/java/com/sunyard/sge/database/SydApi4Database.java +++ b/src/main/java/com/sunyard/sge/database/SydApi4Database.java @@ -114,6 +114,7 @@ public class SydApi4Database implements SydApi { } catch (SydApiException e) { le = e; if (e.getRetCode() < 0) { + log.error("HA 重试"); continue; } throw e; @@ -155,6 +156,7 @@ public class SydApi4Database implements SydApi { } catch (SydApiException e) { le = e; if (e.getRetCode() < 0) { + log.error("HA 重试"); continue; } throw e; @@ -199,6 +201,7 @@ public class SydApi4Database implements SydApi { } catch (SydApiException e) { le = e; if (e.getRetCode() < 0) { + log.error("HA 重试"); continue; } throw e; @@ -244,6 +247,7 @@ public class SydApi4Database implements SydApi { } catch (SydApiException e) { le = e; if (e.getRetCode() < 0) { + log.error("HA 重试"); continue; } throw e; @@ -291,6 +295,7 @@ public class SydApi4Database implements SydApi { } catch (SydApiException e) { le = e; if (e.getRetCode() < 0) { + log.error("HA 重试"); continue; } throw e; @@ -332,6 +337,7 @@ public class SydApi4Database implements SydApi { } catch (SydApiException e) { le = e; if (e.getRetCode() < 0) { + log.error("HA 重试"); continue; } throw e; @@ -373,6 +379,7 @@ public class SydApi4Database implements SydApi { } catch (SydApiException e) { le = e; if (e.getRetCode() < 0) { + log.error("HA 重试"); continue; } throw e; @@ -477,6 +484,7 @@ public class SydApi4Database implements SydApi { } catch (SydApiException e) { le = e; if (e.getRetCode() < 0) { + log.error("HA 重试"); continue; } throw e; diff --git a/src/test/java/test/FuncTest.java b/src/test/java/test/FuncTest.java index 282f45b..bb66b5a 100644 --- a/src/test/java/test/FuncTest.java +++ b/src/test/java/test/FuncTest.java @@ -57,7 +57,7 @@ public class FuncTest { @Test - public void origin() throws Exception { + public void originLong() throws Exception { SydApiBuilder builder = new SydApiBuilder(new String[]{"192.168.0.200"}, new int[]{8889}, 10, 15); SydApi.SYD_SetLogConfig("./logs/",3); Logger log = LogFactory.getLogger(); @@ -73,4 +73,30 @@ public class FuncTest { }, i + "t").start(); } } + @Test + public void originShort() throws Exception { + SydApi.SYD_SetLogConfig("./logs/",3); + Logger log = LogFactory.getLogger(); + String[] pcipList = {"192.168.0.200", "192.168.0.200", "192.168.0.200" }; + int[] iportList ={8080,8889,8889}; + + for (int i = 0; i < 1000; i++) { + int tmp = i; + new Thread(() -> { + try { + SydApi api = new SydApi4Database(); + for (int j = 0; j < 20; j++) { + api.SYD_Short_Connect_Ex(pcipList,iportList,10,15); + byte[] bytes = api.SYD_SM4_ShortData(0, (tmp + "t" + j).getBytes(), Consts.ECB_ENC); + byte[] result = api.SYD_SM4_ShortData(0, bytes, Consts.ECB_DEC); + System.out.println(Thread.currentThread().getName() + "," + new String(result)); + } + } + finally { + if ( null != api ) { + api.SYD_Disconnect_Ex(); + } + } } , i + "t").start(); + } + } }