mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
REPO-4556 Lock prop cleanup and LDAP with same token (#532)
This commit is contained in:
@@ -1,33 +1,34 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.repo.attributes;
|
||||
|
||||
import org.alfresco.repo.domain.propval.PropertyValueDAO;
|
||||
import org.alfresco.repo.lock.JobLockService;
|
||||
import org.alfresco.repo.lock.LockAcquisitionException;
|
||||
import org.alfresco.repo.security.sync.ChainingUserRegistrySynchronizer;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
@@ -74,11 +75,14 @@ public class PropTablesCleaner
|
||||
{
|
||||
checkProperties();
|
||||
|
||||
String lockToken = null;
|
||||
String propCleanUplockToken = null;
|
||||
String ldapSyncLockTocken = null;
|
||||
try
|
||||
{
|
||||
// Get a lock
|
||||
lockToken = jobLockService.getLock(LOCK_QNAME, LOCK_TTL);
|
||||
// Get a lock for cleanup
|
||||
propCleanUplockToken = jobLockService.getLock(LOCK_QNAME, LOCK_TTL);
|
||||
// Get a lock for LDAP sync as well, see REPO-4556
|
||||
ldapSyncLockTocken = jobLockService.getLock(ChainingUserRegistrySynchronizer.LOCK_QNAME, LOCK_TTL);
|
||||
propertyValueDAO.cleanupUnusedValues();
|
||||
}
|
||||
catch (LockAcquisitionException e)
|
||||
@@ -90,11 +94,22 @@ public class PropTablesCleaner
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (lockToken != null)
|
||||
if (propCleanUplockToken != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
jobLockService.releaseLock(lockToken, LOCK_QNAME);
|
||||
jobLockService.releaseLock(propCleanUplockToken, LOCK_QNAME);
|
||||
}
|
||||
catch (LockAcquisitionException e)
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (ldapSyncLockTocken != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
jobLockService.releaseLock(ldapSyncLockTocken, ChainingUserRegistrySynchronizer.LOCK_QNAME);
|
||||
}
|
||||
catch (LockAcquisitionException e)
|
||||
{
|
||||
|
@@ -113,7 +113,7 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
||||
private static final Log logger = LogFactory.getLog(ChainingUserRegistrySynchronizer.class);
|
||||
|
||||
/** The name of the lock used to ensure that a synchronize does not run on more than one node at the same time. */
|
||||
private static final QName LOCK_QNAME = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI,
|
||||
public static final QName LOCK_QNAME = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI,
|
||||
"ChainingUserRegistrySynchronizer");
|
||||
|
||||
/** The time this lock will persist for in the database (now only 2 minutes but refreshed at regular intervals). */
|
||||
|
Reference in New Issue
Block a user