CLOUDSTACK-3458: network GC thread - acquire global lock to prevent multiple MS from running the GC thread on the network at the same time

This commit is contained in:
Alena Prokharchyk 2013-07-10 16:27:31 -07:00
parent a3660d8109
commit 3984287434
1 changed files with 15 additions and 1 deletions

View File

@ -3016,9 +3016,23 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
}
public class NetworkGarbageCollector implements Runnable {
@Override
public void run() {
GlobalLock gcLock = GlobalLock.getInternLock("Network.GC.Lock");
try {
if(gcLock.lock(3)) {
try {
reallyRun();
} finally {
gcLock.unlock();
}
}
} finally {
gcLock.releaseRef();
}
}
public void reallyRun() {
try {
List<Long> shutdownList = new ArrayList<Long>();
long currentTime = System.currentTimeMillis() / 1000 ;