Class MongoIndexSet

java.lang.Object
org.graylog2.indexer.MongoIndexSet
All Implemented Interfaces:
Comparable<IndexSet>, IndexSet

public class MongoIndexSet extends Object implements IndexSet
  • Field Details

  • Constructor Details

  • Method Details

    • getManagedIndices

      public String[] getManagedIndices()
      Description copied from interface: IndexSet
      Returns an array with all managed indices in this index set.

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

      Specified by:
      getManagedIndices in interface IndexSet
      Returns:
      array of index names
    • getWriteIndexAlias

      public String getWriteIndexAlias()
      Description copied from interface: IndexSet
      Returns the write index alias name for this index set.

      The write index alias always points to the newest index.

      Example: "graylog_deflector"

      Specified by:
      getWriteIndexAlias in interface IndexSet
      Returns:
      the write index alias name
    • getIndexWildcard

      public String getIndexWildcard()
      Description copied from interface: IndexSet
      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_*"

      Specified by:
      getIndexWildcard in interface IndexSet
      Returns:
      the index wildcard
    • getNewestIndex

      public String getNewestIndex() throws NoTargetIndexException
      Description copied from interface: IndexSet
      Returns the newest index.

      Example: "graylog_42"

      Specified by:
      getNewestIndex in interface IndexSet
      Returns:
      the newest index
      Throws:
      NoTargetIndexException - if there are no indices in this index set yet
    • extractIndexNumber

      public Optional<Integer> extractIndexNumber(String indexName)
      Description copied from interface: IndexSet
      Extracts the index number from an index name.

      Example: "graylog_42" => 42

      Specified by:
      extractIndexNumber in interface IndexSet
      Parameters:
      indexName - index name
      Returns:
      a filled Optional with the extracted index number, an empty one if the number couldn't be parsed
    • getActiveWriteIndex

      @Nullable public String getActiveWriteIndex() throws TooManyAliasesException
      Description copied from interface: IndexSet
      Returns the active write index.

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

      Example: "graylog_42"

      Specified by:
      getActiveWriteIndex in interface IndexSet
      Returns:
      the active write index
      Throws:
      TooManyAliasesException - if the write index alias points to more than one index
    • getAllIndexAliases

      public Map<String,Set<String>> getAllIndexAliases()
      Description copied from interface: IndexSet
      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}

      Specified by:
      getAllIndexAliases in interface IndexSet
      Returns:
      map of index names to index aliases
    • getIndexPrefix

      public String getIndexPrefix()
      Description copied from interface: IndexSet
      Returns the index prefix for this index set.

      Example: "graylog"

      Specified by:
      getIndexPrefix in interface IndexSet
      Returns:
      index prefix for this index set
    • isUp

      public boolean isUp()
      Description copied from interface: IndexSet
      Checks if the write index alias exists.
      Specified by:
      isUp in interface IndexSet
      Returns:
      true if the write index alias exists, false if not
    • isWriteIndexAlias

      public boolean isWriteIndexAlias(String index)
      Description copied from interface: IndexSet
      Checks if the given index name is equals to the write index alias.
      Specified by:
      isWriteIndexAlias in interface IndexSet
      Parameters:
      index - index name to check
      Returns:
      true if given index name is the write index alias, false if not
    • isManagedIndex

      public boolean isManagedIndex(String index)
      Description copied from interface: IndexSet
      Checks if the given index name is part of this index set.
      Specified by:
      isManagedIndex in interface IndexSet
      Parameters:
      index - index name to check
      Returns:
      true if part of index set, false if not
    • setUp

      public void setUp()
      Description copied from interface: IndexSet
      Prepares this index set to receive new messages.
      Specified by:
      setUp in interface IndexSet
    • cycle

      public void cycle()
      Description copied from interface: IndexSet
      Creates a new index and points the write index alias to it.
      Specified by:
      cycle in interface IndexSet
    • cleanupAliases

      public void cleanupAliases(Set<String> indexNames)
      Description copied from interface: IndexSet
      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.

      Specified by:
      cleanupAliases in interface IndexSet
      Parameters:
      indexNames - list of indices where the index alias points to
    • pointTo

      public void pointTo(String newIndexName, String oldIndexName)
      Description copied from interface: IndexSet
      Changes the write index alias from the old index to the new one.
      Specified by:
      pointTo in interface IndexSet
      Parameters:
      newIndexName - index to add the write index alias to
      oldIndexName - index to remove the write index alias from
    • getConfig

      public IndexSetConfig getConfig()
      Description copied from interface: IndexSet
      The configuration for this index set.
      Specified by:
      getConfig in interface IndexSet
      Returns:
      index set configuration object
    • compareTo

      public int compareTo(IndexSet o)
      Specified by:
      compareTo in interface Comparable<IndexSet>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object