use of org.graylog2.indexer.indices.Indices in project graylog2-server by Graylog2.
the class SearchesIT method determineAffectedIndicesWithRangesDoesNotIncludesDeflectorTargetIfMissing.
@Test
public void determineAffectedIndicesWithRangesDoesNotIncludesDeflectorTargetIfMissing() throws Exception {
final DateTime now = DateTime.now(DateTimeZone.UTC);
final MongoIndexRange indexRange0 = MongoIndexRange.create("graylog_0", now, now.plusDays(1), now, 0);
final MongoIndexRange indexRange1 = MongoIndexRange.create("graylog_1", now.plusDays(1), now.plusDays(2), now, 0);
final SortedSet<IndexRange> indices = ImmutableSortedSet.orderedBy(IndexRange.COMPARATOR).add(indexRange0).add(indexRange1).build();
when(indexRangeService.find(any(DateTime.class), any(DateTime.class))).thenReturn(indices);
final TimeRange absoluteRange = AbsoluteRange.create(now.minusDays(1), now.plusDays(1));
final TimeRange keywordRange = KeywordRange.create("1 day ago", "Etc/UTC");
final TimeRange relativeRange = RelativeRange.create(3600);
assertThat(searches.determineAffectedIndicesWithRanges(absoluteRange, null)).containsExactly(indexRange0, indexRange1);
assertThat(searches.determineAffectedIndicesWithRanges(keywordRange, null)).containsExactly(indexRange0, indexRange1);
assertThat(searches.determineAffectedIndicesWithRanges(relativeRange, null)).containsExactly(indexRange0, indexRange1);
}
use of org.graylog2.indexer.indices.Indices in project graylog2-server by Graylog2.
the class SearchesIT method determineAffectedIndicesFilterIndexPrefix.
@Test
public void determineAffectedIndicesFilterIndexPrefix() throws Exception {
final DateTime now = DateTime.now(DateTimeZone.UTC);
final MongoIndexRange indexRange0 = MongoIndexRange.create("graylog_0", now, now.plusDays(1), now, 0);
final MongoIndexRange indexRange1 = MongoIndexRange.create("graylog_1", now.plusDays(1), now.plusDays(2), now, 0);
final MongoIndexRange b0 = MongoIndexRange.create("b_0", now.plusDays(1), now.plusDays(2), now, 0);
final MongoIndexRange b1 = MongoIndexRange.create("b_1", now.plusDays(1), now.plusDays(2), now, 0);
final SortedSet<IndexRange> indices = ImmutableSortedSet.orderedBy(IndexRange.COMPARATOR).add(indexRange0).add(indexRange1).add(b0).add(b1).build();
final Stream bStream = mock(Stream.class);
when(indexRangeService.find(any(DateTime.class), any(DateTime.class))).thenReturn(indices);
when(streamService.load(eq("123456789ABCDEF"))).thenReturn(bStream);
final IndexSet indexSet = mock(IndexSet.class);
when(indexSet.isManagedIndex(startsWith("b_"))).thenReturn(true);
when(bStream.getIndexSet()).thenReturn(indexSet);
final TimeRange absoluteRange = AbsoluteRange.create(now.minusDays(1), now.plusDays(1));
assertThat(searches.determineAffectedIndices(absoluteRange, "streams:123456789ABCDEF")).containsOnly(b0.indexName(), b1.indexName());
}
use of org.graylog2.indexer.indices.Indices in project graylog2-server by Graylog2.
the class IndexFieldTypePollerIT method setUp.
@Before
public void setUp() throws Exception {
final Node node = mock(Node.class);
@SuppressWarnings("UnstableApiUsage") final Indices indices = new Indices(new IndexMappingFactory(node, ImmutableMap.of(MESSAGE_TEMPLATE_TYPE, new MessageIndexTemplateProvider())), mock(NodeId.class), new NullAuditEventSender(), mock(EventBus.class), createIndicesAdapter());
poller = new IndexFieldTypePoller(indices, new MetricRegistry(), createIndexFieldTypePollerAdapter());
indexSet = new TestIndexSet(indexSetConfig);
importFixture("org/graylog2/indexer/fieldtypes/IndexFieldTypePollerIT.json");
}
use of org.graylog2.indexer.indices.Indices in project graylog2-server by Graylog2.
the class IndexRotationThreadTest method testDoNotPerformRotationIfClusterIsDown.
@Test
public void testDoNotPerformRotationIfClusterIsDown() throws NoTargetIndexException {
final Provider<RotationStrategy> provider = spy(new RotationStrategyProvider());
when(cluster.isConnected()).thenReturn(false);
final IndexRotationThread rotationThread = new IndexRotationThread(notificationService, indices, indexSetRegistry, cluster, new NullActivityWriter(), nodeId, ImmutableMap.<String, Provider<RotationStrategy>>builder().put("strategy", provider).build());
rotationThread.doRun();
verify(indexSet, never()).cycle();
verify(provider, never()).get();
}
use of org.graylog2.indexer.indices.Indices in project graylog2-server by Graylog2.
the class IndexRotationThreadTest method testPerformRotation.
@Test
public void testPerformRotation() throws NoTargetIndexException {
final Provider<RotationStrategy> provider = new RotationStrategyProvider() {
@Override
public void doRotate(IndexSet indexSet) {
indexSet.cycle();
}
};
final IndexRotationThread rotationThread = new IndexRotationThread(notificationService, indices, indexSetRegistry, cluster, new NullActivityWriter(), nodeId, ImmutableMap.<String, Provider<RotationStrategy>>builder().put("strategy", provider).build());
when(indexSetConfig.rotationStrategyClass()).thenReturn("strategy");
rotationThread.checkForRotation(indexSet);
verify(indexSet, times(1)).cycle();
}
Aggregations