Interface IndexSet

All Superinterfaces:
Comparable<IndexSet>
All Known Implementing Classes:
MongoIndexSet, TestIndexSet

public interface IndexSet extends Comparable<IndexSet>
  • Method Details

    • getManagedIndices

      String[] getManagedIndices()
      Returns an array with all managed indices in this index set.

      Example: ["graylog_0", "graylog_1", "graylog_2"]

      Returns:
      array of index names
    • getWriteIndexAlias

      String getWriteIndexAlias()
      Returns the write index alias name for this index set.

      The write index alias always points to the newest index.

      Example: "graylog_deflector"

      Returns:
      the write index alias name
    • getIndexWildcard

      String getIndexWildcard()
      Returns the index wildcard for this index set.

      This can be used in Elasticsearch queries to match all managed indices in this index set.

      Example: "graylog_*"

      Returns:
      the index wildcard
    • getNewestIndex

      String getNewestIndex() throws NoTargetIndexException
      Returns the newest index.

      Example: "graylog_42"

      Returns:
      the newest index
      Throws:
      NoTargetIndexException - if there are no indices in this index set yet
    • getActiveWriteIndex

      @Nullable String getActiveWriteIndex() throws TooManyAliasesException
      Returns the active write index.

      Incoming messages for this index set will be written into this index.

      Example: "graylog_42"

      Returns:
      the active write index
      Throws:
      TooManyAliasesException - if the write index alias points to more than one index
    • getAllIndexAliases

      Map<String,Set<String>> getAllIndexAliases()
      Returns a map where the key is an index name and the value a set of aliases for this index.

      Only the active write index should have an alias, the other values should be empty.

      Example: {graylog_0=[], graylog_1=[], graylog_2=[graylog_deflector}

      Returns:
      map of index names to index aliases
    • getIndexPrefix

      String getIndexPrefix()
      Returns the index prefix for this index set.

      Example: "graylog"

      Returns:
      index prefix for this index set
    • isUp

      boolean isUp()
      Checks if the write index alias exists.
      Returns:
      true if the write index alias exists, false if not
    • isWriteIndexAlias

      boolean isWriteIndexAlias(String index)
      Checks if the given index name is equals to the write index alias.
      Parameters:
      index - index name to check
      Returns:
      true if given index name is the write index alias, false if not
    • isManagedIndex

      boolean isManagedIndex(String index)
      Checks if the given index name is part of this index set.
      Parameters:
      index - index name to check
      Returns:
      true if part of index set, false if not
    • setUp

      void setUp()
      Prepares this index set to receive new messages.
    • cycle

      void cycle()
      Creates a new index and points the write index alias to it.
    • cleanupAliases

      void cleanupAliases(Set<String> indices)
      This ensures that the write index alias only points to the newest index.

      Can be used to fix the aliases in this index set when a TooManyAliasesException has been thrown.

      Parameters:
      indices - list of indices where the index alias points to
    • pointTo

      void pointTo(String newIndexName, String oldIndexName)
      Changes the write index alias from the old index to the new one.
      Parameters:
      newIndexName - index to add the write index alias to
      oldIndexName - index to remove the write index alias from
    • extractIndexNumber

      Optional<Integer> extractIndexNumber(String index)
      Extracts the index number from an index name.

      Example: "graylog_42" => 42

      Parameters:
      index - index name
      Returns:
      a filled Optional with the extracted index number, an empty one if the number couldn't be parsed
    • getConfig

      IndexSetConfig getConfig()
      The configuration for this index set.
      Returns:
      index set configuration object