Fix #150
This commit is contained in:
parent
2e36f7f397
commit
e3276d0114
@ -35,6 +35,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
import java.util.concurrent.locks.Condition;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
@ -58,6 +59,8 @@ public class DomainsManager {
|
|||||||
|
|
||||||
private final Lock lock = new ReentrantLock();
|
private final Lock lock = new ReentrantLock();
|
||||||
|
|
||||||
|
private Map<String, Condition> dom2ContionMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private Map<String, Lock> dom2LockMap = new ConcurrentHashMap<>();
|
private Map<String, Lock> dom2LockMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -651,18 +654,22 @@ public class DomainsManager {
|
|||||||
dom2LockMap.put(dom.getName(), new ReentrantLock());
|
dom2LockMap.put(dom.getName(), new ReentrantLock());
|
||||||
}
|
}
|
||||||
|
|
||||||
Lock lock = dom2LockMap.get(dom.getName());
|
|
||||||
|
|
||||||
|
|
||||||
synchronized (lock) {
|
|
||||||
raftDomMap.put(dom.getName(), dom);
|
raftDomMap.put(dom.getName(), dom);
|
||||||
dom.init();
|
dom.init();
|
||||||
lock.notifyAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
Loggers.SRV_LOG.info("[NEW-DOM-raft] " + dom.toJSON());
|
Loggers.SRV_LOG.info("[NEW-DOM-raft] " + dom.toJSON());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Lock lock = dom2LockMap.get(dom.getName());
|
||||||
|
Condition condition = dom2ContionMap.get(dom.getName());
|
||||||
|
|
||||||
|
try {
|
||||||
|
lock.lock();
|
||||||
|
condition.signalAll();
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Loggers.SRV_LOG.error("VIPSRV-DOM", "error while processing dom update", e);
|
Loggers.SRV_LOG.error("VIPSRV-DOM", "error while processing dom update", e);
|
||||||
}
|
}
|
||||||
@ -690,6 +697,12 @@ public class DomainsManager {
|
|||||||
return lock;
|
return lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Condition addCondtion(String domName) {
|
||||||
|
Condition condition = dom2LockMap.get(domName).newCondition();
|
||||||
|
dom2ContionMap.put(domName, condition);
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, Domain> getDomMap() {
|
public Map<String, Domain> getDomMap() {
|
||||||
return new HashMap<String, Domain>(domMap);
|
return new HashMap<String, Domain>(domMap);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user