Search in sources :

Example 36 with Indices

use of org.graylog2.indexer.indices.Indices in project graylog2-server by Graylog2.

the class IndexCreatingDatabaseOperation method insert.

@Override
public void insert(InputStream dataScript) {
    waitForGreenStatus();
    final IndicesAdminClient indicesAdminClient = client.admin().indices();
    for (String index : indexes) {
        final IndicesExistsResponse indicesExistsResponse = indicesAdminClient.prepareExists(index).execute().actionGet();
        if (indicesExistsResponse.isExists()) {
            client.admin().indices().prepareDelete(index).execute().actionGet();
        }
        final Messages messages = new Messages(client, new MetricRegistry());
        final Indices indices = new Indices(client, new IndexMapping(), messages, mock(NodeId.class), new NullAuditEventSender());
        if (!indices.create(index, indexSet)) {
            throw new IllegalStateException("Couldn't create index " + index);
        }
    }
    databaseOperation.insert(dataScript);
}
Also used : NullAuditEventSender(org.graylog2.audit.NullAuditEventSender) IndexMapping(org.graylog2.indexer.IndexMapping) Messages(org.graylog2.indexer.messages.Messages) MetricRegistry(com.codahale.metrics.MetricRegistry) IndicesExistsResponse(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse) NodeId(org.graylog2.plugin.system.NodeId) Indices(org.graylog2.indexer.indices.Indices) IndicesAdminClient(org.elasticsearch.client.IndicesAdminClient)

Example 37 with Indices

use of org.graylog2.indexer.indices.Indices 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

IndexSet (org.graylog2.indexer.IndexSet)14 Test (org.junit.Test)12 IndexRange (org.graylog2.indexer.ranges.IndexRange)10 Set (java.util.Set)9 ZonedDateTime (java.time.ZonedDateTime)6 Map (java.util.Map)6 DateTime (org.joda.time.DateTime)6 Timed (com.codahale.metrics.annotation.Timed)5 ApiOperation (io.swagger.annotations.ApiOperation)5 ApiResponses (io.swagger.annotations.ApiResponses)5 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Collectors (java.util.stream.Collectors)5 Inject (javax.inject.Inject)5 POST (javax.ws.rs.POST)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 AuditEvent (org.graylog2.audit.jersey.AuditEvent)5 MongoIndexRange (org.graylog2.indexer.ranges.MongoIndexRange)5 TimeRange (org.graylog2.plugin.indexer.searches.timeranges.TimeRange)5