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
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
* provided under the following open source license terms:
|
* provided under the following open source license terms:
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.attributes;
|
package org.alfresco.repo.attributes;
|
||||||
|
|
||||||
import org.alfresco.repo.domain.propval.PropertyValueDAO;
|
import org.alfresco.repo.domain.propval.PropertyValueDAO;
|
||||||
import org.alfresco.repo.lock.JobLockService;
|
import org.alfresco.repo.lock.JobLockService;
|
||||||
import org.alfresco.repo.lock.LockAcquisitionException;
|
import org.alfresco.repo.lock.LockAcquisitionException;
|
||||||
|
import org.alfresco.repo.security.sync.ChainingUserRegistrySynchronizer;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
@@ -74,11 +75,14 @@ public class PropTablesCleaner
|
|||||||
{
|
{
|
||||||
checkProperties();
|
checkProperties();
|
||||||
|
|
||||||
String lockToken = null;
|
String propCleanUplockToken = null;
|
||||||
|
String ldapSyncLockTocken = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get a lock
|
// Get a lock for cleanup
|
||||||
lockToken = jobLockService.getLock(LOCK_QNAME, LOCK_TTL);
|
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();
|
propertyValueDAO.cleanupUnusedValues();
|
||||||
}
|
}
|
||||||
catch (LockAcquisitionException e)
|
catch (LockAcquisitionException e)
|
||||||
@@ -90,11 +94,22 @@ public class PropTablesCleaner
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (lockToken != null)
|
if (propCleanUplockToken != null)
|
||||||
{
|
{
|
||||||
try
|
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)
|
catch (LockAcquisitionException e)
|
||||||
{
|
{
|
||||||
|
@@ -113,7 +113,7 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
|
|||||||
private static final Log logger = LogFactory.getLog(ChainingUserRegistrySynchronizer.class);
|
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. */
|
/** 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");
|
"ChainingUserRegistrySynchronizer");
|
||||||
|
|
||||||
/** The time this lock will persist for in the database (now only 2 minutes but refreshed at regular intervals). */
|
/** 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