use of org.graylog2.indexer.MongoIndexSet 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.MongoIndexSet in project graylog2-server by Graylog2.
the class MongoIndexSetTest method cycleSetsOldIndexToReadOnly.
@Test
public void cycleSetsOldIndexToReadOnly() throws SystemJobConcurrencyException {
final String newIndexName = "graylog_1";
final String oldIndexName = "graylog_0";
final Map<String, Set<String>> indexNameAliases = ImmutableMap.of(oldIndexName, Collections.singleton("graylog_deflector"));
when(indices.getIndexNamesAndAliases(anyString())).thenReturn(indexNameAliases);
when(indices.create(newIndexName, mongoIndexSet)).thenReturn(true);
when(indices.waitForRecovery(newIndexName)).thenReturn(HealthStatus.Green);
final SetIndexReadOnlyAndCalculateRangeJob rangeJob = mock(SetIndexReadOnlyAndCalculateRangeJob.class);
when(jobFactory.create(oldIndexName)).thenReturn(rangeJob);
final MongoIndexSet mongoIndexSet = createIndexSet(config);
mongoIndexSet.cycle();
verify(jobFactory, times(1)).create(oldIndexName);
verify(systemJobManager, times(1)).submitWithDelay(rangeJob, 30L, TimeUnit.SECONDS);
}
use of org.graylog2.indexer.MongoIndexSet in project graylog2-server by Graylog2.
the class MongoIndexSetTest method identifiesRestoredArchivesAsBeingManaged.
@Test
public void identifiesRestoredArchivesAsBeingManaged() {
final IndexSetConfig restoredArchives = config.toBuilder().title("Restored Archives").description("Indices which have been restored from an archive.").indexPrefix("restored-archive").indexMatchPattern("restored-archive\\S*").indexWildcard("restored-archive*").build();
final String indexName = restoredArchives.indexPrefix() + "-graylog_33";
final MongoIndexSet mongoIndexSet = createIndexSet(restoredArchives);
assertThat(mongoIndexSet.isManagedIndex(indexName)).isTrue();
}
use of org.graylog2.indexer.MongoIndexSet in project graylog2-server by Graylog2.
the class MongoIndexSetRegistryTest method isManagedIndexWithUnmanagedIndexReturnsFalse.
@Test
public void isManagedIndexWithUnmanagedIndexReturnsFalse() {
final IndexSetConfig indexSetConfig = mock(IndexSetConfig.class);
final List<IndexSetConfig> indexSetConfigs = Collections.singletonList(indexSetConfig);
final MongoIndexSet indexSet = mock(MongoIndexSet.class);
when(mongoIndexSetFactory.create(indexSetConfig)).thenReturn(indexSet);
when(indexSetService.findAll()).thenReturn(indexSetConfigs);
when(indexSet.isManagedIndex("index")).thenReturn(false);
assertThat(indexSetRegistry.isManagedIndex("index")).isFalse();
}
use of org.graylog2.indexer.MongoIndexSet in project graylog2-server by Graylog2.
the class MongoIndexSetRegistryTest method isManagedIndexReturnsAMapOfIndices.
@Test
public void isManagedIndexReturnsAMapOfIndices() {
final IndexSetConfig indexSetConfig = mock(IndexSetConfig.class);
final List<IndexSetConfig> indexSetConfigs = Collections.singletonList(indexSetConfig);
final MongoIndexSet indexSet = mock(MongoIndexSet.class);
when(mongoIndexSetFactory.create(indexSetConfig)).thenReturn(indexSet);
when(indexSetService.findAll()).thenReturn(indexSetConfigs);
when(indexSet.isManagedIndex("index1")).thenReturn(true);
when(indexSet.isManagedIndex("index2")).thenReturn(false);
final Map<String, Boolean> managedStatus = indexSetRegistry.isManagedIndex(ImmutableSet.of("index1", "index2"));
assertThat(managedStatus).containsEntry("index1", true).containsEntry("index2", false);
}
Aggregations