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
Nested ClassesModifier and TypeClassDescriptionstatic classThis 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
ConstructorsConstructorDescriptionLookupDataAdapterRefreshService(ScheduledExecutorService scheduler, ConcurrentMap<String, LookupTable> liveTables) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(LookupDataAdapter dataAdapter) Add the givenLookupDataAdapterto the refresh service.newServiceListener(LookupDataAdapter adapter) Returns a newService.Listenerto add and remove the given data adapter to the refresh service.voidremove(LookupDataAdapter dataAdapter) Remove the givenLookupDataAdapterfrom the refresh service.protected voidshutDown()protected voidstartUp()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:
startUpin classcom.google.common.util.concurrent.AbstractIdleService- Throws:
Exception
-
shutDown
- Specified by:
shutDownin classcom.google.common.util.concurrent.AbstractIdleService- Throws:
Exception
-
newServiceListener
Returns a newService.Listenerto 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 givenLookupDataAdapterto the refresh service.The
refresh methodmethod will be called periodically according to therefresh intervalof the data adapter.- Parameters:
dataAdapter- the adapter to be added
-
remove
Remove the givenLookupDataAdapterfrom the refresh service.- Parameters:
dataAdapter-
-