Search in sources :

Example 1 with IndexRangeService

use of org.graylog2.indexer.ranges.IndexRangeService in project graylog2-server by Graylog2.

the class SearchesTest method setUp.

@Before
public void setUp() throws Exception {
    when(indexRangeService.find(any(DateTime.class), any(DateTime.class))).thenReturn(INDEX_RANGES);
    metricRegistry = new MetricRegistry();
    searches = new Searches(new Configuration(), indexRangeService, client, metricRegistry, streamService, mock(Indices.class));
}
Also used : Configuration(org.graylog2.Configuration) MetricRegistry(com.codahale.metrics.MetricRegistry) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) Before(org.junit.Before)

Example 2 with IndexRangeService

use of org.graylog2.indexer.ranges.IndexRangeService 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(ClusterHealthStatus.GREEN);
    final SetIndexReadOnlyAndCalculateRangeJob rangeJob = mock(SetIndexReadOnlyAndCalculateRangeJob.class);
    when(jobFactory.create(oldIndexName)).thenReturn(rangeJob);
    final MongoIndexSet mongoIndexSet = new MongoIndexSet(config, indices, nodeId, indexRangeService, auditEventSender, systemJobManager, jobFactory, activityWriter);
    mongoIndexSet.cycle();
    verify(jobFactory, times(1)).create(oldIndexName);
    verify(systemJobManager, times(1)).submitWithDelay(rangeJob, 30L, TimeUnit.SECONDS);
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) SetIndexReadOnlyAndCalculateRangeJob(org.graylog2.indexer.indices.jobs.SetIndexReadOnlyAndCalculateRangeJob) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 3 with IndexRangeService

use of org.graylog2.indexer.ranges.IndexRangeService in project graylog2-server by Graylog2.

the class MongoIndexRangeServiceTest method setUp.

@Before
public void setUp() throws Exception {
    localEventBus = new EventBus("local-event-bus");
    indexRangeService = new MongoIndexRangeService(mongoRule.getMongoConnection(), objectMapperProvider, indices, indexSetRegistry, new NullAuditEventSender(), mock(NodeId.class), localEventBus);
}
Also used : NullAuditEventSender(org.graylog2.audit.NullAuditEventSender) EventBus(com.google.common.eventbus.EventBus) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 EventBus (com.google.common.eventbus.EventBus)1 ZonedDateTime (java.time.ZonedDateTime)1 Set (java.util.Set)1 Configuration (org.graylog2.Configuration)1 NullAuditEventSender (org.graylog2.audit.NullAuditEventSender)1 SetIndexReadOnlyAndCalculateRangeJob (org.graylog2.indexer.indices.jobs.SetIndexReadOnlyAndCalculateRangeJob)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1