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(); + } + } }