Package org.keycloak.cluster.infinispan
Class InfinispanClusterProvider
java.lang.Object
org.keycloak.cluster.infinispan.InfinispanClusterProvider
- All Implemented Interfaces:
ClusterProvider
,Provider
- Author:
- Marek Posolda
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.keycloak.cluster.ClusterProvider
ClusterProvider.DCNotify
-
Field Summary
-
Constructor Summary
ConstructorDescriptionInfinispanClusterProvider
(int clusterStartupTime, String myAddress, org.keycloak.cluster.infinispan.CrossDCAwareCacheFactory crossDCAwareCacheFactory, InfinispanNotificationsManager notificationsManager, ExecutorService localExecutor) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
<T> ExecutionResult<T>
executeIfNotExecuted
(String taskKey, int taskTimeoutInSeconds, Callable<T> task) Execute given task just if it's not already in progress (either on this or any other cluster node).executeIfNotExecutedAsync
(String taskKey, int taskTimeoutInSeconds, Callable task) Execute given task just if it's not already in progress (either on this or any other cluster node).int
Same value for all cluster nodes.void
notify
(String taskKey, Collection<? extends ClusterEvent> events, boolean ignoreSender, ClusterProvider.DCNotify dcNotify) An alternative toClusterProvider.notify(String, ClusterEvent, boolean, DCNotify)
that sends multiple events in a single network call.void
notify
(String taskKey, ClusterEvent event, boolean ignoreSender, ClusterProvider.DCNotify dcNotify) Notify registered listeners on all cluster nodes in all datacenters.void
registerListener
(String taskKey, ClusterListener task) Register task (listener) under given key.
-
Field Details
-
logger
protected static final org.jboss.logging.Logger logger -
CLUSTER_STARTUP_TIME_KEY
- See Also:
-
TASK_KEY_PREFIX
- See Also:
-
-
Constructor Details
-
InfinispanClusterProvider
public InfinispanClusterProvider(int clusterStartupTime, String myAddress, org.keycloak.cluster.infinispan.CrossDCAwareCacheFactory crossDCAwareCacheFactory, InfinispanNotificationsManager notificationsManager, ExecutorService localExecutor)
-
-
Method Details
-
getClusterStartupTime
public int getClusterStartupTime()Description copied from interface:ClusterProvider
Same value for all cluster nodes. It will use startup time of this server in non-cluster environment.- Specified by:
getClusterStartupTime
in interfaceClusterProvider
-
close
public void close() -
executeIfNotExecuted
public <T> ExecutionResult<T> executeIfNotExecuted(String taskKey, int taskTimeoutInSeconds, Callable<T> task) Description copied from interface:ClusterProvider
Execute given task just if it's not already in progress (either on this or any other cluster node).- Specified by:
executeIfNotExecuted
in interfaceClusterProvider
taskTimeoutInSeconds
- timeout for given task. If there is existing task in progress for longer time, it's considered outdated so we will start our task.- Returns:
- result with "executed" flag specifying if execution was executed or ignored.
-
executeIfNotExecutedAsync
public Future<Boolean> executeIfNotExecutedAsync(String taskKey, int taskTimeoutInSeconds, Callable task) Description copied from interface:ClusterProvider
Execute given task just if it's not already in progress (either on this or any other cluster node). It will return corresponding future to every caller and this future is fulfilled if: - The task is successfully finished. In that case Future will be true - The task wasn't successfully finished. For example because cluster node failover. In that case Future will be false- Specified by:
executeIfNotExecutedAsync
in interfaceClusterProvider
taskTimeoutInSeconds
- timeout for given task. If there is existing task in progress for longer time, it's considered outdated so we will start our task.- Returns:
- Future, which will be completed once the running task is finished. Returns true if task was successfully finished. Otherwise (for example if cluster node when task was running leaved cluster) returns false
-
registerListener
Description copied from interface:ClusterProvider
Register task (listener) under given key. When this key will be put to the cache on any cluster node, the task will be executed.- Specified by:
registerListener
in interfaceClusterProvider
-
notify
public void notify(String taskKey, ClusterEvent event, boolean ignoreSender, ClusterProvider.DCNotify dcNotify) Description copied from interface:ClusterProvider
Notify registered listeners on all cluster nodes in all datacenters. It will notify listeners registered under given taskKey- Specified by:
notify
in interfaceClusterProvider
ignoreSender
- if true, then sender node itself won't receive the notificationdcNotify
- Specify which DCs to notify. SeeClusterProvider.DCNotify
enum values for more info
-
notify
public void notify(String taskKey, Collection<? extends ClusterEvent> events, boolean ignoreSender, ClusterProvider.DCNotify dcNotify) Description copied from interface:ClusterProvider
An alternative toClusterProvider.notify(String, ClusterEvent, boolean, DCNotify)
that sends multiple events in a single network call.Notifies registered listeners on all cluster nodes in all datacenters. It will notify listeners registered under given
taskKey
- Specified by:
notify
in interfaceClusterProvider
- See Also:
-