Merge remote-tracking branch 'origin/dev-1.0' into dev-1.0

This commit is contained in:
junj2.liang 2022-08-05 18:49:54 +08:00
commit bd3fc80c7f
3 changed files with 30 additions and 11 deletions

View File

@ -16,9 +16,11 @@ import java.util.List;
public class SydApi4Database implements SydApi { public class SydApi4Database implements SydApi {
Logger log = LogFactory.getLogger(); Logger log = LogFactory.getLogger();
private SydApi4j[] hsms = null; private SydApi4j[] hsms = null;
private boolean isShortLinkMode = false;
@Deprecated @Deprecated
public SydApi4Database() { public SydApi4Database() {
isShortLinkMode = true;
} }
public SydApi4Database(SydApi4j[] hsms) { public SydApi4Database(SydApi4j[] hsms) {
@ -31,20 +33,23 @@ public class SydApi4Database implements SydApi {
log.debug("SYD_Connect_Ex方法接收参数:pcIpList:{},iPortList:{},iConnectTimeOut:{},iDealTimeOut:{}", Arrays.toString(pcIpList), Arrays.toString(iPortList), iConnectTimeOut, iDealTimeOut); log.debug("SYD_Connect_Ex方法接收参数:pcIpList:{},iPortList:{},iConnectTimeOut:{},iDealTimeOut:{}", Arrays.toString(pcIpList), Arrays.toString(iPortList), iConnectTimeOut, iDealTimeOut);
} }
SydApi4j api = (SydApi4j) new SydApi4j().connect(pcIpList[0], iPortList[0], null, iConnectTimeOut); SydApi4j api = (SydApi4j) new SydApi4j().connect(pcIpList[0], iPortList[0], null, iConnectTimeOut);
hsms = new SydApi4j[]{ api }; hsms = new SydApi4j[]{api};
return this; return this;
} }
@Override @Override
public void SYD_Disconnect_Ex() { public void SYD_Disconnect_Ex() {
if (isShortLinkMode) {
SydApi4j api = hsms[0];
if (null != api) {
try {
api.disconnect();
} catch (Exception e) {
}
}
api = null;
}
// 配合链接池不再需要释放 // 配合链接池不再需要释放
// if ( null != api ) {
// try {
// api.disconnect();
// }catch ( Exception e ){
// }
// }
// api = null;
} }
@Override @Override

View File

@ -42,11 +42,25 @@ public class SydApiPool extends ThreadBasedConnectPool<SydApi> {
// 保活接口 // 保活接口
protected boolean check(SydApi o) { protected boolean check(SydApi o) {
return null != o; if ( null == o ) {
return false;
}
try {
o.SYD_SM3_Hash_ShortData( new byte[8] );
return true;
}catch ( Exception e) {
// 忽略
return false;
}
} }
// 释放 // 释放
protected void free(SydApi o) { protected void free(SydApi o) {
if ( null != o ) {
o.SYD_Disconnect_Ex();
}
} }
} }

View File

@ -3,10 +3,10 @@ package com.sunyard.sge.pool;
public class PoolConfig { public class PoolConfig {
// 最大空闲时间 // 最大空闲时间
private long maxIdle = 5 * 3600 * 1000; // 5 分钟 private long maxIdle = 5 * 60 * 1000; // 5 分钟
// 最大无用时间 // 最大无用时间
private long maxUseless = 30 * 3600 * 1000; // 30 分钟 private long maxUseless = 30 * 60 * 1000; // 30 分钟
public long getMaxIdle() { public long getMaxIdle() {
return maxIdle; return maxIdle;