Package fr.becpg.util

Class MutexFactory

java.lang.Object
fr.becpg.util.MutexFactory

@Component public class MutexFactory extends Object

MutexFactory class.

Version:
$Id: $Id
Author:
matthieu
  • Field Details

    • LOCK_TIMEOUT

      private static final Long LOCK_TIMEOUT
    • logger

      private static final org.apache.commons.logging.Log logger
    • memoryMap

      private org.springframework.util.ConcurrentReferenceHashMap<String,ReentrantLock> memoryMap
    • clusterMap

      private org.springframework.util.ConcurrentReferenceHashMap<String,MutexFactory.JobLockWrapper> clusterMap
    • jobLockService

      @Autowired private org.alfresco.repo.lock.JobLockService jobLockService
  • Constructor Details

    • MutexFactory

      public MutexFactory()

      Constructor for MutexFactory.

  • Method Details

    • getMutex

      public ReentrantLock getMutex(String key)

      getMutex.

      Returns a memory-only lock for entity-level synchronization. Use this for entity-specific locks (formulate-{nodeId}) to avoid: - Deadlock in beforeCommit during init-repo - Pollution of alf_lock_resource with dynamic QNames
      Parameters:
      key - a String object
      Returns:
      a ReentrantLock object
    • getClusterMutex

      public ReentrantLock getClusterMutex(String key, String lockName)

      getClusterMutex.

      Returns a cluster-aware lock using JobLockService for global job synchronization. Use this for global job locks (projectformulationjob, entityactivityjob, etc.) to ensure only one node in the cluster executes the job at a time.
      Parameters:
      key - a String object (used for the ReentrantLock map)
      lockName - a String object (used as QName local name for JobLockService)
      Returns:
      a ReentrantLock object
    • removeMutex

      public void removeMutex(String key, Object value)

      removeMutex.

      Parameters:
      key - a String object
      value - a Object object