This commit is contained in:
junj2.liang 2022-09-13 15:57:21 +08:00
parent 53c1e93115
commit 4e2f6b3ac4
5 changed files with 79 additions and 52 deletions

View File

@ -26,6 +26,19 @@ public class SydApi4Database extends SydApiBaseFunction {
}
@Override
public List<byte[]> SYD_SM4_BatchData(int[] iKeyIndex, List<byte[]> pcData, int iFlag) {
if ( null == iKeyIndex || null == pcData ) {
throw new IllegalArgumentException("批量输入数据为 null");
}
if ( iKeyIndex.length != pcData.size() ) {
throw new IllegalArgumentException("批量输入数据密钥和数据数量不等");
}
if ( 0 == iKeyIndex.length ) {
return new ArrayList<>();
}
// 将数据进行分组防止超长
List<List<byte[]>> dataGroups = new ArrayList<>();
List<List<Integer>> keyGroups = new ArrayList<>();
@ -72,6 +85,19 @@ public class SydApi4Database extends SydApiBaseFunction {
@Override
public String[] SYD_SM4Mac_BatchData(int[] iKeyIndex, List<byte[]> pcData) {
if ( null == iKeyIndex || null == pcData ) {
throw new IllegalArgumentException("批量输入数据为 null");
}
if ( iKeyIndex.length != pcData.size() ) {
throw new IllegalArgumentException("批量输入数据密钥和数据数量不等");
}
if ( 0 == iKeyIndex.length ) {
return new String[0];
}
// 将数据进行分组防止超长
List<List<byte[]>> dataGroups = new ArrayList<>();
List<List<Integer>> keyGroups = new ArrayList<>();
@ -116,6 +142,19 @@ public class SydApi4Database extends SydApiBaseFunction {
@Override
public boolean[] SYD_SM4Mac_BatchData(int[] iKeyIndex, List<byte[]> pcData, String[] pcMac) {
if ( null == iKeyIndex || null == pcData ) {
throw new IllegalArgumentException("批量输入数据为 null");
}
if ( iKeyIndex.length != pcData.size() ) {
throw new IllegalArgumentException("批量输入数据密钥和数据数量不等");
}
if ( 0 == iKeyIndex.length ) {
return new boolean[0];
}
// 将数据进行分组防止超长
List<List<byte[]>> dataGroups = new ArrayList<>();
List<List<Integer>> keyGroups = new ArrayList<>();

View File

@ -172,6 +172,18 @@ public class SydApiLongLinkWrap implements SydApi {
@Override
public List<byte[]> SYD_SM4_BatchData(int[] iKeyIndex, List<byte[]> pcData, int iFlag) {
if ( null == iKeyIndex || null == pcData ) {
throw new IllegalArgumentException("批量输入数据为 null");
}
if ( iKeyIndex.length != pcData.size() ) {
throw new IllegalArgumentException("批量输入数据密钥和数据数量不等");
}
if ( 0 == iKeyIndex.length ) {
return new ArrayList<>();
}
// 将数据进行分组防止超长
List<List<byte[]>> dataGroups = new ArrayList<>();
List<List<Integer>> keyGroups = new ArrayList<>();
@ -236,6 +248,18 @@ public class SydApiLongLinkWrap implements SydApi {
@Override
public String[] SYD_SM4Mac_BatchData(int[] iKeyIndex, List<byte[]> pcData) {
if ( null == iKeyIndex || null == pcData ) {
throw new IllegalArgumentException("批量输入数据为 null");
}
if ( iKeyIndex.length != pcData.size() ) {
throw new IllegalArgumentException("批量输入数据密钥和数据数量不等");
}
if ( 0 == iKeyIndex.length ) {
return new String[0];
}
// 将数据进行分组防止超长
List<List<byte[]>> dataGroups = new ArrayList<>();
List<List<Integer>> keyGroups = new ArrayList<>();
@ -299,6 +323,20 @@ public class SydApiLongLinkWrap implements SydApi {
@Override
public boolean[] SYD_SM4Mac_BatchData(int[] iKeyIndex, List<byte[]> pcData, String[] pcMac) {
if ( null == iKeyIndex || null == pcData ) {
throw new IllegalArgumentException("批量输入数据为 null");
}
if ( iKeyIndex.length != pcData.size() ) {
throw new IllegalArgumentException("批量输入数据密钥和数据数量不等");
}
if ( 0 == iKeyIndex.length ) {
return new boolean[0];
}
// 将数据进行分组防止超长
List<List<byte[]>> dataGroups = new ArrayList<>();
List<List<Integer>> keyGroups = new ArrayList<>();

View File

@ -12,7 +12,7 @@ public class PoolConfig {
private int keepAliveNumber = 5;
// 最大连接数
private int maxAliveNumber = 100;
private int maxAliveNumber = 30;
public long getMaxIdle() {
return maxIdle;

View File

@ -1,50 +0,0 @@
package sample;
import com.sunyard.SydApi;
import racal.sunyard.main.SydApi4j;
import racal.sunyard.main.SydApiBuilder;
public class ConnectThread extends Thread {
public SydApi getApi() {
SydApiBuilder builder = new SydApiBuilder().setIp("172.16.18.59");
SydApi4j papi = (SydApi4j) builder.build();
// SydApi4j papi = (SydApi4j) new SydApi4j().connect("172.16.18.59" , 8889, null,1000);
return papi;
}
public static void main(String[] args) {
// logger.info("测试开始");
int n = Runtime.getRuntime().availableProcessors();
int max = 1001;
Thread[] tList = new Thread[max];
for (int i = 0; i < max; i++) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
ConnectThread stable = new ConnectThread();
SydApi api = stable.getApi();
try {
// SydApi api = stable.getApi();
} catch (Exception e) {
e.printStackTrace();
}
}
});
tList[i] = thread;
}
for (Thread t : tList) {
t.start();
}
for (Thread t : tList) {
try {
t.join();
} catch (InterruptedException e3) {
e3.printStackTrace();
}
}
}
}

View File

@ -79,7 +79,7 @@ public class FuncTest {
SydApi api = new SydApi4Database();
try {
for (int j = 0; j < 20; j++) {
api.SYD_Short_Connect_Ex(pcipList,iportList,10,15);
api.SYD_Short_Connect_Ex(pcipList,iportList,50,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);
}