Package org.graylog2.indexer
Interface IndexSet
- All Superinterfaces:
Comparable<IndexSet>
- All Known Implementing Classes:
MongoIndexSet
,TestIndexSet
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanupAliases
(Set<String> indices) This ensures that the write index alias only points to the newest index.void
cycle()
Creates a new index and points the write index alias to it.extractIndexNumber
(String index) Extracts the index number from an index name.Returns the active write index.Returns a map where the key is an index name and the value a set of aliases for this index.The configuration for this index set.Returns the index prefix for this index set.Returns the index wildcard for this index set.String[]
Returns an array with all managed indices in this index set.Returns the newest index.Returns the write index alias name for this index set.boolean
isManagedIndex
(String index) Checks if the given index name is part of this index set.boolean
isUp()
Checks if the write index alias exists.boolean
isWriteIndexAlias
(String index) Checks if the given index name is equals to the write index alias.void
Changes the write index alias from the old index to the new one.void
setUp()
Prepares this index set to receive new messages.Methods inherited from interface java.lang.Comparable
compareTo
-
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
Returns the newest index.Example:
"graylog_42"
- Returns:
- the newest index
- Throws:
NoTargetIndexException
- if there are no indices in this index set yet
-
getActiveWriteIndex
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
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
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
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
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
Changes the write index alias from the old index to the new one.- Parameters:
newIndexName
- index to add the write index alias tooldIndexName
- index to remove the write index alias from
-
extractIndexNumber
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
-