public class MongoIndexSet extends Object implements IndexSet
| Modifier and Type | Class and Description |
|---|---|
static interface |
MongoIndexSet.Factory |
IndexSet.IndexNameComparator| Modifier and Type | Field and Description |
|---|---|
static String |
DEFLECTOR_SUFFIX |
static String |
RESTORED_ARCHIVE_SUFFIX |
static String |
SEPARATOR |
| Constructor and Description |
|---|
MongoIndexSet(IndexSetConfig config,
Indices indices,
NodeId nodeId,
IndexRangeService indexRangeService,
AuditEventSender auditEventSender,
SystemJobManager systemJobManager,
SetIndexReadOnlyAndCalculateRangeJob.Factory jobFactory,
ActivityWriter activityWriter) |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanupAliases(Set<String> indexNames)
This ensures that the write index alias only points to the newest index.
|
int |
compareTo(IndexSet o) |
void |
cycle()
Creates a new index and points the write index alias to it.
|
boolean |
equals(Object o) |
Optional<Integer> |
extractIndexNumber(String indexName)
Extracts the index number from an index name.
|
String |
getActiveWriteIndex()
Returns the active write index.
|
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.
|
IndexSetConfig |
getConfig()
The configuration for this index set.
|
String |
getIndexPrefix()
Returns the index prefix for this index set.
|
String |
getIndexWildcard()
Returns the index wildcard for this index set.
|
String[] |
getManagedIndices()
Returns an array with all managed indices in this index set.
|
String |
getNewestIndex()
Returns the newest index.
|
String |
getWriteIndexAlias()
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 |
pointTo(String newIndexName,
String oldIndexName)
Changes the write index alias from the old index to the new one.
|
void |
setUp()
Prepares this index set to receive new messages.
|
String |
toString() |
public static final String SEPARATOR
public static final String DEFLECTOR_SUFFIX
public static final String RESTORED_ARCHIVE_SUFFIX
@Inject public MongoIndexSet(IndexSetConfig config, Indices indices, NodeId nodeId, IndexRangeService indexRangeService, AuditEventSender auditEventSender, SystemJobManager systemJobManager, SetIndexReadOnlyAndCalculateRangeJob.Factory jobFactory, ActivityWriter activityWriter)
public String[] getManagedIndices()
IndexSet
Example: ["graylog_0", "graylog_1", "graylog_2"]
getManagedIndices in interface IndexSetpublic String getWriteIndexAlias()
IndexSetThe write index alias always points to the newest index.
Example: "graylog_deflector"
getWriteIndexAlias in interface IndexSetpublic String getIndexWildcard()
IndexSetThis can be used in Elasticsearch queries to match all managed indices in this index set.
Example: "graylog_*"
getIndexWildcard in interface IndexSetpublic String getNewestIndex() throws NoTargetIndexException
IndexSet
Example: "graylog_42"
getNewestIndex in interface IndexSetNoTargetIndexException - if there are no indices in this index set yetpublic Optional<Integer> extractIndexNumber(String indexName)
IndexSet
Example: "graylog_42" => 42
extractIndexNumber in interface IndexSetindexName - index nameOptional with the extracted index number, an empty one if the number couldn't be parsed@Nullable public String getActiveWriteIndex() throws TooManyAliasesException
IndexSetIncoming messages for this index set will be written into this index.
Example: "graylog_42"
getActiveWriteIndex in interface IndexSetTooManyAliasesException - if the write index alias points to more than one indexpublic Map<String,Set<String>> getAllIndexAliases()
IndexSetOnly the active write index should have an alias, the other values should be empty.
Example: {graylog_0=[], graylog_1=[], graylog_2=[graylog_deflector}
getAllIndexAliases in interface IndexSetpublic String getIndexPrefix()
IndexSet
Example: "graylog"
getIndexPrefix in interface IndexSetpublic boolean isUp()
IndexSetpublic boolean isWriteIndexAlias(String index)
IndexSetisWriteIndexAlias in interface IndexSetindex - index name to checkpublic boolean isManagedIndex(String index)
IndexSetisManagedIndex in interface IndexSetindex - index name to checkpublic void setUp()
IndexSetpublic void cycle()
IndexSetpublic void cleanupAliases(Set<String> indexNames)
IndexSet
Can be used to fix the aliases in this index set when a TooManyAliasesException has been thrown.
cleanupAliases in interface IndexSetindexNames - list of indices where the index alias points topublic void pointTo(String newIndexName, String oldIndexName)
IndexSetpublic IndexSetConfig getConfig()
IndexSetpublic int compareTo(IndexSet o)
compareTo in interface Comparable<IndexSet>Copyright © 2012–2021 Graylog, Inc.. All rights reserved.