53 lines
1.6 KiB
Java
53 lines
1.6 KiB
Java
package sample;
|
|
|
|
import com.sunyard.SydApi;
|
|
import com.sunyard.proto.Util;
|
|
import racal.sunyard.main.SydApiClusterBuilder;
|
|
|
|
|
|
/**
|
|
* 集群模式 - 短连接
|
|
*/
|
|
public class HSMPoolShortLink {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
// 调试模式
|
|
System.setProperty("com.sunyard.sydapi4j.debug", "true");
|
|
|
|
// 建立链接
|
|
final String[] pcipList = {"172.16.18.59", "192.168.0.200"};
|
|
final int[] iportList = {8889, 8889};
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
int tmp = i;
|
|
new Thread(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
SydApi api = SydApiClusterBuilder.SYD_Short_Connect_Ex(
|
|
pcipList,
|
|
iportList,
|
|
10,
|
|
1000);
|
|
try {
|
|
for (int j = 0; j < 20; j++) {
|
|
byte[] data = api.SM3Hash("test".getBytes());
|
|
System.out.println("hex=" + Util.bytes2HexString(data));
|
|
// boolean sign = api.deleteCert("C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1");
|
|
// System.out.println(sign);
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
if (null != api) {
|
|
api.disconnect();
|
|
}
|
|
}
|
|
}
|
|
}).start();
|
|
}
|
|
}
|
|
}
|