Class SynchronizationPool

java.lang.Object
cz.metacentrum.perun.core.impl.SynchronizationPool

public class SynchronizationPool extends Object
Class used for scheduling group and group structure synchronizations. It does not run any scheduler, it just provides the functionality for the scheduling of synchronizations.

Methods in this class are thread safe

Author:
Peter Balčirák peter.balcirak@gmail.com
  • Constructor Details

    • SynchronizationPool

      public SynchronizationPool()
  • Method Details

    • asPoolOfGroupsStructuresToBeSynchronized

      public PerunBeanProcessingPool<Group> asPoolOfGroupsStructuresToBeSynchronized()
      Method for accessing the pool of groups structures
      Returns:
      groups structures processing pool
    • asPoolOfGroupsToBeSynchronized

      public PerunBeanProcessingPool<Group> asPoolOfGroupsToBeSynchronized()
      Method for accessing the pool of groups structures
      Returns:
      groups processing pool
    • putGroupStructureToPoolOfWaitingGroupsStructures

      public boolean putGroupStructureToPoolOfWaitingGroupsStructures(Group group, boolean asFirst)
      Put group to the pool of waiting groups structures.
      Parameters:
      group - which will be added to the pool of waiting group structures
      asFirst - true if group will skip order and will be placed to the list as first (LIFO)
      Returns:
      Throws:
      InternalErrorException
    • putGroupToPoolOfWaitingGroups

      public boolean putGroupToPoolOfWaitingGroups(Group group, boolean asFirst)
      Put group to the pool of waiting groups.
      Parameters:
      group - which will be added to the pool of waiting groups
      asFirst - true if group will skip order and will be placed to the list as first (LIFO)
      Returns:
      Throws:
      InternalErrorException
    • putGroupsStructuresToPoolOfWaitingGroupsStructures

      public int putGroupsStructuresToPoolOfWaitingGroupsStructures(List<Group> groups)
      Put list of groups to the pool of waiting groups structures.
      Parameters:
      groups - which will be added to the pool of waiting group structures
      Returns:
      Throws:
      InternalErrorException
    • putGroupsToPoolOfWaitingGroups

      public int putGroupsToPoolOfWaitingGroups(List<Group> groups)
      Put list of groups to the pool of waiting groups.
      Parameters:
      groups - which will be added to the pool of waiting groups
      Returns:
      Throws:
      InternalErrorException
    • removeGroup

      public boolean removeGroup(Group group)
      Remove group from the pool of running groups

      This method does not use poolAccessLock because of performance improvement. Locking is done in PerunBeanProcessingPool.

      Parameters:
      group - which will be removed from the pool of running groups structures
      Returns:
    • removeGroupStructure

      public boolean removeGroupStructure(Group group)
      Remove group from the pool of running groups structures

      This method does not use poolAccessLock because of performance improvement. Locking is done in PerunBeanProcessingPool.

      Parameters:
      group - which will be removed from the pool of running groups structures
      Returns:
    • takeGroup

      public Group takeGroup(PerunSessionImpl sess) throws InterruptedException
      Take a first group, which can be safely synchronized, from the pool of waiting groups and add it to the pool of running groups. If the group does not exists anymore, remove it from the pool of waiting groups, wait 1-2 seconds and try the whole process again. We cannot remove more than one group during the one while loop because of the concurrent use of semaphore. If none of the waiting groups can be synchronized, wait 1-2 seconds and try the whole process again.
      Parameters:
      sess -
      Returns:
      Throws:
      InterruptedException
      InternalErrorException
    • takeGroupStructure

      public Group takeGroupStructure(PerunSessionImpl sess) throws InterruptedException
      Take a first group, which can be safely synchronized, from the pool of waiting groups structures and add it to the pool of running groups structures. If none of the waiting groups can be taken, wait 1-2 seconds and try again.
      Parameters:
      sess -
      Returns:
      Throws:
      InterruptedException
      InternalErrorException