Class LookupDataAdapter

java.lang.Object
com.google.common.util.concurrent.AbstractIdleService
org.graylog2.plugin.lookup.LookupDataAdapter
All Implemented Interfaces:
com.google.common.util.concurrent.Service
Direct Known Subclasses:
AbuseChRansomAdapter, CSVFileDataAdapter, DnsLookupDataAdapter, DSVHTTPDataAdapter, GreyNoiseCommunityIpLookupAdapter, GreyNoiseQuickIPDataAdapter, HTTPJSONPathDataAdapter, MaxmindDataAdapter, OTXDataAdapter, SpamhausEDROPDataAdapter, TorExitNodeDataAdapter, WhoisDataAdapter

public abstract class LookupDataAdapter extends com.google.common.util.concurrent.AbstractIdleService
  • Constructor Details

    • LookupDataAdapter

      protected LookupDataAdapter(DataAdapterDto dto, com.codahale.metrics.MetricRegistry metricRegistry)
    • LookupDataAdapter

      protected LookupDataAdapter(String id, String name, LookupDataAdapterConfiguration config, com.codahale.metrics.MetricRegistry metricRegistry)
  • Method Details

    • getErrorResult

      public LookupResult getErrorResult()
    • getEmptyResult

      public LookupResult getEmptyResult()
    • startUp

      protected void startUp() throws Exception
      Specified by:
      startUp in class com.google.common.util.concurrent.AbstractIdleService
      Throws:
      Exception
    • doStart

      protected abstract void doStart() throws Exception
      Throws:
      Exception
    • shutDown

      protected void shutDown() throws Exception
      Specified by:
      shutDown in class com.google.common.util.concurrent.AbstractIdleService
      Throws:
      Exception
    • doStop

      protected abstract void doStop() throws Exception
      Throws:
      Exception
    • refreshInterval

      public abstract org.joda.time.Duration refreshInterval()
      Returns the refresh interval for this data adapter. Use Duration.ZERO if refresh should be disabled.
      Returns:
      the refresh interval
    • refresh

      public void refresh(LookupCachePurge cachePurge)
    • doRefresh

      protected abstract void doRefresh(LookupCachePurge cachePurge) throws Exception
      Throws:
      Exception
    • clearError

      protected void clearError()
    • getError

      public Optional<Throwable> getError()
    • setError

      protected void setError(Throwable throwable)
    • id

      public String id()
    • name

      public String name()
    • get

      public LookupResult get(Object key)
    • doGet

      protected abstract LookupResult doGet(Object key)
    • set

      @Deprecated public abstract void set(Object key, Object value)
      Deprecated.
    • setValue

      public LookupResult setValue(Object key, Object value)
      Update a value for the given key in a DataAdapter. This is a method stub that can be implemented in DataAdapters that support this kind of data modification.
      Parameters:
      key - The key that should be updated.
      value - The new value.
      Returns:
      A LookupResult containing the updated value or an error
    • setValueWithTtl

      public LookupResult setValueWithTtl(Object key, Object value, Long ttlSec)
      Update a value for the given key in a DataAdapter and assign a TTL. This is a method stub that can be implemented in DataAdapters that support this kind of data modification.
      Parameters:
      key - The key that should be updated.
      value - The new value.
      ttlSec - The time to live in seconds to assigned to this entry.
      Returns:
      A LookupResult containing the updated value or an error
    • setStringList

      public LookupResult setStringList(Object key, List<String> listValue)
      Update all list entries for the given key in a DataAdapter. This is a method stub that can be implemented in DataAdapters that support this kind of data modification.
      Parameters:
      key - The key that should be updated.
      listValue - The new list values.
      Returns:
      A LookupResult containing the updated list or an error
    • setStringListWithTtl

      public LookupResult setStringListWithTtl(Object key, List<String> listValue, Long ttlSec)
      Update all list entries for the given key in a DataAdapter and assign a TTL. This is a method stub that can be implemented in DataAdapters that support this kind of data modification.
      Parameters:
      key - The key that should be updated.
      listValue - The new list values.
      ttlSec - The time to live in seconds to assigned to this entry.
      Returns:
      A LookupResult containing the updated list or an error
    • addStringList

      public LookupResult addStringList(Object key, List<String> listValue, boolean keepDuplicates)
      Merge / append all list entries for the given key in a DataAdapter. This is a method stub that can be implemented in DataAdapters that support this kind of data modification.
      Parameters:
      key - The key that should be updated.
      listValue - The list values that should be merged / appended.
      keepDuplicates - Controls whether duplicated entries should be unified.
      Returns:
      A LookupResult containing the updated list or an error
    • removeStringList

      public LookupResult removeStringList(Object key, List<String> listValue)
      Remove all matching list entries for the given key in a DataAdapter. This is a method stub that can be implemented in DataAdapters that support this kind of data modification.
      Parameters:
      key - The key that should be updated.
      listValue - The list values that should be removed.
      Returns:
      A LookupResult containing the updated list or an error
    • clearKey

      public void clearKey(Object key)
      Clear (remove) the given key from the lookup table.
      Parameters:
      key - The key that should be cleared.
    • assignTtl

      public LookupResult assignTtl(Object key, Long ttlSec)
      Update / add a time to live for the given key in a DataAdapter. This is a method stub that can be implemented in DataAdapters that support TTLs.
      Parameters:
      key - The key that should be updated.
      ttlSec - The time to live in seconds that should be assigned.
      Returns:
      A LookupResult containing the updated value or an error
    • getConfig

      public LookupDataAdapterConfiguration getConfig()