Search in sources :

Example 1 with IndexTemplateNotFoundException

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

the class Indices method ensureIndexTemplate.

public void ensureIndexTemplate(IndexSet indexSet) {
    final IndexSetConfig indexSetConfig = indexSet.getConfig();
    final String templateName = indexSetConfig.indexTemplateName();
    try {
        final Map<String, Object> template = buildTemplate(indexSet, indexSetConfig);
        if (indicesAdapter.ensureIndexTemplate(templateName, template)) {
            LOG.info("Successfully ensured index template {}", templateName);
        } else {
            LOG.warn("Failed to create index template {}", templateName);
        }
    } catch (IgnoreIndexTemplate e) {
        LOG.warn(e.getMessage());
        if (e.isFailOnMissingTemplate() && !indicesAdapter.indexTemplateExists(templateName)) {
            throw new IndexTemplateNotFoundException(f("No index template with name '%s' (type - '%s') found in Elasticsearch", templateName, indexSetConfig.indexTemplateType().orElse(null)));
        }
    }
}
Also used : IndexSetConfig(org.graylog2.indexer.indexset.IndexSetConfig) IndexTemplateNotFoundException(org.graylog2.indexer.IndexTemplateNotFoundException) IgnoreIndexTemplate(org.graylog2.indexer.IgnoreIndexTemplate)

Aggregations

IgnoreIndexTemplate (org.graylog2.indexer.IgnoreIndexTemplate)1 IndexTemplateNotFoundException (org.graylog2.indexer.IndexTemplateNotFoundException)1 IndexSetConfig (org.graylog2.indexer.indexset.IndexSetConfig)1