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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanupAliases(Set<String> indices) This ensures that the write index alias only points to the newest index.intvoidcycle()Creates a new index and points the write index alias to it.booleanextractIndexNumber(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.inthashCode()booleanisManagedIndex(String index) Checks if the given index name is part of this index set.booleanisUp()Checks if the write index alias exists.booleanisWriteIndexAlias(String index) Checks if the given index name is equals to the write index alias.voidChanges the write index alias from the old index to the new one.voidsetUp()Prepares this index set to receive new messages.toString()
-
Field Details
-
config
-
-
Constructor Details
-
TestIndexSet
-
-
Method Details
-
getManagedIndices
Description copied from interface:IndexSetReturns an array with all managed indices in this index set.Example:
["graylog_0", "graylog_1", "graylog_2"]- Specified by:
getManagedIndicesin interfaceIndexSet- Returns:
- array of index names
-
getWriteIndexAlias
Description copied from interface:IndexSetReturns the write index alias name for this index set.The write index alias always points to the newest index.
Example:
"graylog_deflector"- Specified by:
getWriteIndexAliasin interfaceIndexSet- Returns:
- the write index alias name
-
getIndexWildcard
Description copied from interface:IndexSetReturns 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:
getIndexWildcardin interfaceIndexSet- Returns:
- the index wildcard
-
getNewestIndex
Description copied from interface:IndexSetReturns the newest index.Example:
"graylog_42"- Specified by:
getNewestIndexin interfaceIndexSet- Returns:
- the newest index
- Throws:
NoTargetIndexException- if there are no indices in this index set yet
-
getActiveWriteIndex
Description copied from interface:IndexSetReturns the active write index.Incoming messages for this index set will be written into this index.
Example:
"graylog_42"- Specified by:
getActiveWriteIndexin interfaceIndexSet- Returns:
- the active write index
- Throws:
TooManyAliasesException- if the write index alias points to more than one index
-
getAllIndexAliases
Description copied from interface:IndexSetReturns 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:
getAllIndexAliasesin interfaceIndexSet- Returns:
- map of index names to index aliases
-
getIndexPrefix
Description copied from interface:IndexSetReturns the index prefix for this index set.Example:
"graylog"- Specified by:
getIndexPrefixin interfaceIndexSet- Returns:
- index prefix for this index set
-
isUp
public boolean isUp()Description copied from interface:IndexSetChecks if the write index alias exists. -
isWriteIndexAlias
Description copied from interface:IndexSetChecks if the given index name is equals to the write index alias.- Specified by:
isWriteIndexAliasin 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:IndexSetChecks if the given index name is part of this index set.- Specified by:
isManagedIndexin 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:IndexSetPrepares this index set to receive new messages. -
cycle
public void cycle()Description copied from interface:IndexSetCreates a new index and points the write index alias to it. -
cleanupAliases
Description copied from interface:IndexSetThis 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
TooManyAliasesExceptionhas been thrown.- Specified by:
cleanupAliasesin interfaceIndexSet- Parameters:
indices- list of indices where the index alias points to
-
pointTo
Description copied from interface:IndexSetChanges the write index alias from the old index to the new one. -
extractIndexNumber
Description copied from interface:IndexSetExtracts the index number from an index name.Example:
"graylog_42" => 42- Specified by:
extractIndexNumberin interfaceIndexSet- Parameters:
index- index name- Returns:
- a filled
Optionalwith the extracted index number, an empty one if the number couldn't be parsed
-
getConfig
Description copied from interface:IndexSetThe configuration for this index set. -
compareTo
- Specified by:
compareToin interfaceComparable<IndexSet>
-
equals
-
hashCode
public int hashCode() -
toString
-