Merge remote-tracking branch 'origin/dev-1.0' into dev-1.0
This commit is contained in:
commit
bd3fc80c7f
@ -16,9 +16,11 @@ import java.util.List;
|
||||
public class SydApi4Database implements SydApi {
|
||||
Logger log = LogFactory.getLogger();
|
||||
private SydApi4j[] hsms = null;
|
||||
private boolean isShortLinkMode = false;
|
||||
|
||||
@Deprecated
|
||||
public SydApi4Database() {
|
||||
isShortLinkMode = true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
SydApi4j api = (SydApi4j) new SydApi4j().connect(pcIpList[0], iPortList[0], null, iConnectTimeOut);
|
||||
hsms = new SydApi4j[]{ api };
|
||||
hsms = new SydApi4j[]{api};
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
|
||||
@ -42,11 +42,25 @@ public class SydApiPool extends ThreadBasedConnectPool<SydApi> {
|
||||
|
||||
// 保活接口
|
||||
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) {
|
||||
if ( null != o ) {
|
||||
o.SYD_Disconnect_Ex();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,10 +3,10 @@ package com.sunyard.sge.pool;
|
||||
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() {
|
||||
return maxIdle;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user