Package org.graylog2.lookup
Class LookupDataAdapterRefreshService
java.lang.Object
com.google.common.util.concurrent.AbstractIdleService
org.graylog2.lookup.LookupDataAdapterRefreshService
- All Implemented Interfaces:
com.google.common.util.concurrent.Service
public class LookupDataAdapterRefreshService
extends com.google.common.util.concurrent.AbstractIdleService
This is responsible for scheduling
LookupDataAdapter
refreshes.
Every LookupDataAdapter
can be configured to run a refresh job to load new data, do internal cleanup or
similar tasks. This object takes care of scheduling the refresh so the data adapter don't have to do that on
their own.
A service LookupDataAdapterRefreshService.Listener
instance will be attached to every LookupDataAdapter
during startup. The listener
takes care of adding and removing the LookupDataAdapter
from the refresh service when the data adapter
gets started or stopped.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This service listener should be attached to adata adapter service
.Nested classes/interfaces inherited from interface com.google.common.util.concurrent.Service
com.google.common.util.concurrent.Service.State
-
Constructor Summary
ConstructorDescriptionLookupDataAdapterRefreshService
(ScheduledExecutorService scheduler, ConcurrentMap<String, LookupTable> liveTables) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(LookupDataAdapter dataAdapter) Add the givenLookupDataAdapter
to the refresh service.newServiceListener
(LookupDataAdapter adapter) Returns a newService.Listener
to add and remove the given data adapter to the refresh service.void
remove
(LookupDataAdapter dataAdapter) Remove the givenLookupDataAdapter
from the refresh service.protected void
shutDown()
protected void
startUp()
Methods inherited from class com.google.common.util.concurrent.AbstractIdleService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, serviceName, startAsync, state, stopAsync, toString
-
Constructor Details
-
LookupDataAdapterRefreshService
public LookupDataAdapterRefreshService(ScheduledExecutorService scheduler, ConcurrentMap<String, LookupTable> liveTables)
-
-
Method Details
-
startUp
- Specified by:
startUp
in classcom.google.common.util.concurrent.AbstractIdleService
- Throws:
Exception
-
shutDown
- Specified by:
shutDown
in classcom.google.common.util.concurrent.AbstractIdleService
- Throws:
Exception
-
newServiceListener
Returns a newService.Listener
to add and remove the given data adapter to the refresh service.- Parameters:
adapter
- the data adapter to be added/removed- Returns:
- the new listener
-
add
Add the givenLookupDataAdapter
to the refresh service.The
refresh method
method will be called periodically according to therefresh interval
of the data adapter.- Parameters:
dataAdapter
- the adapter to be added
-
remove
Remove the givenLookupDataAdapter
from the refresh service.- Parameters:
dataAdapter
-
-