mirror of
https://gitee.com/BDWare/common
synced 2025-01-09 17:34:16 +00:00
update docker files
This commit is contained in:
parent
2ef0e29890
commit
eff8d37278
@ -51,7 +51,7 @@ dependencies {
|
|||||||
//api 'org.apache.velocity:velocity-engine-core:2.3'
|
//api 'org.apache.velocity:velocity-engine-core:2.3'
|
||||||
api 'org.rocksdb:rocksdbjni:7.3.1'
|
api 'org.rocksdb:rocksdbjni:7.3.1'
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
implementation 'org.bdware.doip:doip-sdk:1.5.5'
|
implementation 'org.bdware.doip:doip-sdk:1.5.6'
|
||||||
}
|
}
|
||||||
group = "org.bdware.sc"
|
group = "org.bdware.sc"
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import com.google.gson.JsonPrimitive;
|
|||||||
import io.netty.util.HashedWheelTimer;
|
import io.netty.util.HashedWheelTimer;
|
||||||
import io.netty.util.Timeout;
|
import io.netty.util.Timeout;
|
||||||
import io.netty.util.TimerTask;
|
import io.netty.util.TimerTask;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bdware.sc.ContractResult;
|
import org.bdware.sc.ContractResult;
|
||||||
import org.bdware.sc.ContractResult.Status;
|
import org.bdware.sc.ContractResult.Status;
|
||||||
import org.bdware.sc.util.JsonUtil;
|
import org.bdware.sc.util.JsonUtil;
|
||||||
@ -18,6 +20,27 @@ public class SyncResult {
|
|||||||
new HashedWheelTimer(Executors.defaultThreadFactory(), 5, TimeUnit.MILLISECONDS, 2);
|
new HashedWheelTimer(Executors.defaultThreadFactory(), 5, TimeUnit.MILLISECONDS, 2);
|
||||||
static final String TimeoutStr =
|
static final String TimeoutStr =
|
||||||
JsonUtil.toJson(new ContractResult(Status.Error, new JsonPrimitive("Timeout!")));
|
JsonUtil.toJson(new ContractResult(Status.Error, new JsonPrimitive("Timeout!")));
|
||||||
|
static long syncTime = getSyncTime();
|
||||||
|
static Logger LOGGER = LogManager.getLogger(SyncResult.class);
|
||||||
|
|
||||||
|
private static long getSyncTime() {
|
||||||
|
long retVal;
|
||||||
|
String timeout = System.getenv("BDW_SOCKET_TIMEOUT");
|
||||||
|
if (timeout == null || timeout.isEmpty()) {
|
||||||
|
retVal = 10 * 1000; // 10秒转换为毫秒
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
retVal = Long.parseLong(timeout); // 将秒转换为毫秒
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// 如果环境变量不是有效的数字,返回默认值
|
||||||
|
e.printStackTrace();
|
||||||
|
retVal = 10 * 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOGGER.info("SocketGet Timeout=" + retVal);
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
// private static final org.apache.logging.log4j.Logger LOGGER =
|
// private static final org.apache.logging.log4j.Logger LOGGER =
|
||||||
// org.apache.logging.log4j.LogManager.getLogger(SyncResult.class);
|
// org.apache.logging.log4j.LogManager.getLogger(SyncResult.class);
|
||||||
Map<Long, ResultCallback> waitObj = new ConcurrentHashMap<>();
|
Map<Long, ResultCallback> waitObj = new ConcurrentHashMap<>();
|
||||||
@ -56,7 +79,7 @@ public class SyncResult {
|
|||||||
synchronized (cb) {
|
synchronized (cb) {
|
||||||
try {
|
try {
|
||||||
if (waitObj.containsKey(requestID))
|
if (waitObj.containsKey(requestID))
|
||||||
cb.wait(10000L);
|
cb.wait(syncTime);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user