Package cz.metacentrum.perun.core.impl
Class SynchronizationPool
java.lang.Object
cz.metacentrum.perun.core.impl.SynchronizationPool
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionMethod for accessing the pool of groups structuresMethod for accessing the pool of groups structuresint
Put list of groups to the pool of waiting groups structures.int
putGroupsToPoolOfWaitingGroups
(List<Group> groups) Put list of groups to the pool of waiting groups.boolean
putGroupStructureToPoolOfWaitingGroupsStructures
(Group group, boolean asFirst) Put group to the pool of waiting groups structures.boolean
putGroupToPoolOfWaitingGroups
(Group group, boolean asFirst) Put group to the pool of waiting groups.boolean
removeGroup
(Group group) Remove group from the pool of running groupsboolean
removeGroupStructure
(Group group) Remove group from the pool of running groups structurestakeGroup
(PerunSessionImpl sess) Take a first group, which can be safely synchronized, from the pool of waiting groups and add it to the pool of running groups.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.
-
Constructor Details
-
SynchronizationPool
public SynchronizationPool()
-
-
Method Details
-
asPoolOfGroupsStructuresToBeSynchronized
Method for accessing the pool of groups structures- Returns:
- groups structures processing pool
-
asPoolOfGroupsToBeSynchronized
Method for accessing the pool of groups structures- Returns:
- groups processing pool
-
putGroupStructureToPoolOfWaitingGroupsStructures
Put group to the pool of waiting groups structures.- Parameters:
group
- which will be added to the pool of waiting group structuresasFirst
- true if group will skip order and will be placed to the list as first (LIFO)- Returns:
- Throws:
InternalErrorException
-
putGroupToPoolOfWaitingGroups
Put group to the pool of waiting groups.- Parameters:
group
- which will be added to the pool of waiting groupsasFirst
- true if group will skip order and will be placed to the list as first (LIFO)- Returns:
- Throws:
InternalErrorException
-
putGroupsStructuresToPoolOfWaitingGroupsStructures
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
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
Remove group from the pool of running groupsThis 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
Remove group from the pool of running groups structuresThis 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
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
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
-