use of org.graylog2.indexer.indexset.IndexSetConfig in project graylog2-server by Graylog2.
the class IndexSetsResourceTest method updateDenied.
@Test
public void updateDenied() {
notPermitted();
final IndexSetConfig indexSetConfig = IndexSetConfig.create("id", "title", "description", true, "prefix", 1, 0, MessageCountRotationStrategy.class.getCanonicalName(), MessageCountRotationStrategyConfig.create(1000), NoopRetentionStrategy.class.getCanonicalName(), NoopRetentionStrategyConfig.create(1), ZonedDateTime.of(2016, 10, 10, 12, 0, 0, 0, ZoneOffset.UTC), "standard", "index-template", 1, false);
expectedException.expect(ForbiddenException.class);
expectedException.expectMessage("Not authorized to access resource id <wrong-id>");
try {
indexSetsResource.update("wrong-id", IndexSetUpdateRequest.fromIndexSetConfig(indexSetConfig));
} finally {
verifyZeroInteractions(indexSetService);
}
}
use of org.graylog2.indexer.indexset.IndexSetConfig in project graylog2-server by Graylog2.
the class IndexSetsResourceTest method listDenied.
@Test
public void listDenied() {
notPermitted();
final IndexSetConfig indexSetConfig = IndexSetConfig.create("id", "title", "description", true, "prefix", 1, 0, MessageCountRotationStrategy.class.getCanonicalName(), MessageCountRotationStrategyConfig.create(1000), NoopRetentionStrategy.class.getCanonicalName(), NoopRetentionStrategyConfig.create(1), ZonedDateTime.of(2016, 10, 10, 12, 0, 0, 0, ZoneOffset.UTC), "standard", "index-template", 1, false);
when(indexSetService.findAll()).thenReturn(Collections.singletonList(indexSetConfig));
final IndexSetResponse list = indexSetsResource.list(0, 0, false);
verify(indexSetService, times(1)).findAll();
verify(indexSetService, times(1)).getDefault();
verifyNoMoreInteractions(indexSetService);
assertThat(list.total()).isEqualTo(0);
assertThat(list.indexSets()).isEmpty();
}
use of org.graylog2.indexer.indexset.IndexSetConfig in project graylog2-server by Graylog2.
the class IndexSetsResourceTest method get.
@Test
public void get() {
final IndexSetConfig indexSetConfig = IndexSetConfig.create("id", "title", "description", true, "prefix", 1, 0, MessageCountRotationStrategy.class.getCanonicalName(), MessageCountRotationStrategyConfig.create(1000), NoopRetentionStrategy.class.getCanonicalName(), NoopRetentionStrategyConfig.create(1), ZonedDateTime.of(2016, 10, 10, 12, 0, 0, 0, ZoneOffset.UTC), "standard", "index-template", 1, false);
when(indexSetService.get("id")).thenReturn(Optional.of(indexSetConfig));
final IndexSetSummary summary = indexSetsResource.get("id");
verify(indexSetService, times(1)).get("id");
verify(indexSetService, times(1)).getDefault();
verifyNoMoreInteractions(indexSetService);
assertThat(summary).isEqualTo(IndexSetSummary.fromIndexSetConfig(indexSetConfig, false));
}
use of org.graylog2.indexer.indexset.IndexSetConfig in project graylog2-server by Graylog2.
the class MongoIndexSetService method save.
/**
* {@inheritDoc}
*/
@Override
public IndexSetConfig save(IndexSetConfig indexSetConfig) {
final WriteResult<IndexSetConfig, ObjectId> writeResult = collection.save(indexSetConfig);
final IndexSetConfig savedObject = writeResult.getSavedObject();
final IndexSetCreatedEvent createdEvent = IndexSetCreatedEvent.create(savedObject);
clusterEventBus.post(createdEvent);
return savedObject;
}
use of org.graylog2.indexer.indexset.IndexSetConfig in project graylog2-server by Graylog2.
the class IndexSetCleanupJob method execute.
@Override
public void execute() {
final IndexSetConfig config = indexSet.getConfig();
final String[] managedIndices = indexSet.getManagedIndices();
this.total = managedIndices.length;
try {
LOG.info("Deleting index template <{}> from Elasticsearch", config.indexTemplateName());
indices.deleteIndexTemplate(indexSet);
} catch (IndexTemplateMissingException ignored) {
LOG.debug("Unable to delete index template <{}> because it does not exist.", config.indexTemplateName());
} catch (Exception e) {
LOG.error("Unable to delete index template <{}>", config.indexTemplateName(), e);
}
for (String indexName : managedIndices) {
if (cancel) {
LOG.info("Cancel requested. Deleted <{}> of <{}> indices.", deleted, total);
break;
}
try {
LOG.info("Removing index range information for index: {}", indexName);
indexRangeService.remove(indexName);
LOG.info("Deleting index <{}> in index set <{}> ({})", indexName, config.id(), config.title());
indices.delete(indexName);
deleted.incrementAndGet();
} catch (Exception e) {
LOG.error("Unable to delete index <{}>", indexName, e);
}
}
}
Aggregations