修改启动es集群启动

This commit is contained in:
chenshaohua
2026-03-30 12:59:15 +08:00
parent 4f97d729c4
commit b09fc0a3ef
2 changed files with 17 additions and 3 deletions

View File

@@ -94,9 +94,10 @@ public class ESJobSearchImpl implements IESJobSearchService
private boolean acquireDistributedLock() throws InterruptedException {
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < WAIT_LOCK_SECONDS * 1000) {
boolean lockExists = redisCache.hasKey(ES_INIT_LOCK_KEY);
if (!lockExists) {
redisCache.setCacheObject(ES_INIT_LOCK_KEY, "es_init_locked", LOCK_EXPIRE_SECONDS, TimeUnit.SECONDS);
boolean success = redisCache.setIfAbsent(ES_INIT_LOCK_KEY,"es_init_locked",
LOCK_EXPIRE_SECONDS,TimeUnit.SECONDS
);
if (success) {
logger.info("成功获取ES初始化分布式锁key{}", ES_INIT_LOCK_KEY);
return true;
}