Package org.graylog2.indexer
Class TestIndexSet
java.lang.Object
org.graylog2.indexer.TestIndexSet
- All Implemented Interfaces:
Comparable<IndexSet>
,IndexSet
This class is being used in plugins for testing, DO NOT move it to the test/ directory without changing the plugins.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.graylog2.indexer.IndexSet
IndexSet.IndexNameComparator
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanupAliases
(Set<String> indices) This ensures that the write index alias only points to the newest index.int
void
cycle()
Creates a new index and points the write index alias to it.boolean
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.int
hashCode()
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.toString()
-
Field Details
-
config
-
-
Constructor Details
-
TestIndexSet
-
-
Method Details
-
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 interfaceIndexSet
- Returns:
- array of index names
-
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 interfaceIndexSet
- Returns:
- the write index alias name
-
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 interfaceIndexSet
- Returns:
- the index wildcard
-
getNewestIndex
Description copied from interface:IndexSet
Returns the newest index.Example:
"graylog_42"
- Specified by:
getNewestIndex
in interfaceIndexSet
- Returns:
- the newest index
- Throws:
NoTargetIndexException
- if there are no indices in this index set yet
-
getActiveWriteIndex
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 interfaceIndexSet
- Returns:
- the active write index
- Throws:
TooManyAliasesException
- if the write index alias points to more than one index
-
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 interfaceIndexSet
- Returns:
- map of index names to index aliases
-
getIndexPrefix
Description copied from interface:IndexSet
Returns the index prefix for this index set.Example:
"graylog"
- Specified by:
getIndexPrefix
in interfaceIndexSet
- Returns:
- index prefix for this index set
-
isUp
public boolean isUp()Description copied from interface:IndexSet
Checks if the write index alias exists. -
isWriteIndexAlias
Description copied from interface:IndexSet
Checks if the given index name is equals to the write index alias.- Specified by:
isWriteIndexAlias
in interfaceIndexSet
- Parameters:
index
- index name to check- Returns:
- true if given index name is the write index alias, false if not
-
isManagedIndex
Description copied from interface:IndexSet
Checks if the given index name is part of this index set.- Specified by:
isManagedIndex
in interfaceIndexSet
- 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. -
cycle
public void cycle()Description copied from interface:IndexSet
Creates a new index and points the write index alias to it. -
cleanupAliases
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 interfaceIndexSet
- Parameters:
indices
- list of indices where the index alias points to
-
pointTo
Description copied from interface:IndexSet
Changes the write index alias from the old index to the new one. -
extractIndexNumber
Description copied from interface:IndexSet
Extracts the index number from an index name.Example:
"graylog_42" => 42
- Specified by:
extractIndexNumber
in interfaceIndexSet
- Parameters:
index
- index name- Returns:
- a filled
Optional
with the extracted index number, an empty one if the number couldn't be parsed
-
getConfig
Description copied from interface:IndexSet
The configuration for this index set. -
compareTo
- Specified by:
compareTo
in interfaceComparable<IndexSet>
-
equals
-
hashCode
public int hashCode() -
toString
-