use of org.jumpmind.db.sql.ConcurrencySqlException in project symmetric-ds by JumpMind.
the class ClusterService method lockCluster.
protected boolean lockCluster(String action, Date timeToBreakLock, Date timeLockAcquired, String serverId) {
if (isClusteringEnabled()) {
try {
return sqlTemplate.update(getSql("acquireClusterLockSql"), new Object[] { serverId, timeLockAcquired, action, TYPE_CLUSTER, timeToBreakLock, serverId }) == 1;
} catch (ConcurrencySqlException ex) {
log.debug("Ignoring concurrency error and reporting that we failed to get the cluster lock: {}", ex.getMessage());
}
} else {
Lock lock = lockCache.get(action);
if (lock != null) {
synchronized (lock) {
if (lock.getLockType().equals(TYPE_CLUSTER) && (lock.getLockTime() == null || lock.getLockTime().before(timeToBreakLock) || serverId.equals(lock.getLockingServerId()))) {
lock.setLockingServerId(serverId);
lock.setLockTime(timeLockAcquired);
return true;
}
}
}
}
return false;
}
Aggregations