use of org.graylog2.indexer.indexset.IndexSetConfig in project graylog2-server by Graylog2.
the class ClosingRetentionStrategy method getMaxNumberOfIndices.
@Override
protected Optional<Integer> getMaxNumberOfIndices(IndexSet indexSet) {
final IndexSetConfig indexSetConfig = indexSet.getConfig();
final RetentionStrategyConfig strategyConfig = indexSetConfig.retentionStrategy();
if (!(strategyConfig instanceof ClosingRetentionStrategyConfig)) {
throw new IllegalStateException("Invalid retention strategy config <" + strategyConfig.getClass().getCanonicalName() + "> for index set <" + indexSetConfig.id() + ">");
}
final ClosingRetentionStrategyConfig config = (ClosingRetentionStrategyConfig) strategyConfig;
return Optional.of(config.maxNumberOfIndices());
}
use of org.graylog2.indexer.indexset.IndexSetConfig in project graylog2-server by Graylog2.
the class DeletionRetentionStrategy method getMaxNumberOfIndices.
@Override
protected Optional<Integer> getMaxNumberOfIndices(IndexSet indexSet) {
final IndexSetConfig indexSetConfig = indexSet.getConfig();
final RetentionStrategyConfig strategyConfig = indexSetConfig.retentionStrategy();
if (!(strategyConfig instanceof DeletionRetentionStrategyConfig)) {
throw new IllegalStateException("Invalid retention strategy config <" + strategyConfig.getClass().getCanonicalName() + "> for index set <" + indexSetConfig.id() + ">");
}
final DeletionRetentionStrategyConfig config = (DeletionRetentionStrategyConfig) strategyConfig;
return Optional.of(config.maxNumberOfIndices());
}
use of org.graylog2.indexer.indexset.IndexSetConfig in project graylog2-server by Graylog2.
the class MongoIndexSetRegistry method findAllMongoIndexSets.
private Set<MongoIndexSet> findAllMongoIndexSets() {
final List<IndexSetConfig> configs = this.indexSetsCache.get();
final ImmutableSet.Builder<MongoIndexSet> mongoIndexSets = ImmutableSet.builder();
for (IndexSetConfig config : configs) {
final MongoIndexSet mongoIndexSet = mongoIndexSetFactory.create(config);
mongoIndexSets.add(mongoIndexSet);
}
return mongoIndexSets.build();
}
use of org.graylog2.indexer.indexset.IndexSetConfig in project graylog2-server by Graylog2.
the class SizeBasedRotationStrategyTest method testDontRotate.
@Test
public void testDontRotate() throws Exception {
final CommonStats commonStats = new CommonStats();
commonStats.store = new StoreStats(1000, 0);
final IndexStatistics stats = IndexStatistics.create("name", commonStats, commonStats, Collections.<ShardRouting>emptyList());
when(indices.getIndexStats("name")).thenReturn(stats);
when(indexSet.getNewestIndex()).thenReturn("name");
when(indexSet.getConfig()).thenReturn(indexSetConfig);
when(indexSetConfig.rotationStrategy()).thenReturn(SizeBasedRotationStrategyConfig.create(100000L));
final SizeBasedRotationStrategy strategy = new SizeBasedRotationStrategy(indices, nodeId, auditEventSender);
strategy.rotate(indexSet);
verify(indexSet, never()).cycle();
reset(indexSet);
}
use of org.graylog2.indexer.indexset.IndexSetConfig in project graylog2-server by Graylog2.
the class SizeBasedRotationStrategyTest method testRotate.
@Test
public void testRotate() throws Exception {
final CommonStats commonStats = new CommonStats();
commonStats.store = new StoreStats(1000, 0);
final IndexStatistics stats = IndexStatistics.create("name", commonStats, commonStats, Collections.<ShardRouting>emptyList());
when(indices.getIndexStats("name")).thenReturn(stats);
when(indexSet.getNewestIndex()).thenReturn("name");
when(indexSet.getConfig()).thenReturn(indexSetConfig);
when(indexSetConfig.rotationStrategy()).thenReturn(SizeBasedRotationStrategyConfig.create(100L));
final SizeBasedRotationStrategy strategy = new SizeBasedRotationStrategy(indices, nodeId, auditEventSender);
strategy.rotate(indexSet);
verify(indexSet, times(1)).cycle();
reset(indexSet);
}
Aggregations