@Override public DeleteTemplate build() { return new DeleteTemplate(this); } }
@Override public PutTemplate build() { return new PutTemplate(this); } }
@Override public GetTemplate build() { return new GetTemplate(this); } }
public void ensureIndexTemplate(IndexSet indexSet) { final IndexSetConfig indexSetConfig = indexSet.getConfig(); final String templateName = indexSetConfig.indexTemplateName(); final IndexMapping indexMapping = indexMappingFactory.createIndexMapping(); final Map<String, Object> template = indexMapping.messageTemplate(indexSet.getIndexWildcard(), indexSetConfig.indexAnalyzer(), -1); final PutTemplate request = new PutTemplate.Builder(templateName, template).build(); final JestResult jestResult = JestUtils.execute(jestClient, request, () -> "Unable to create index template " + templateName); if (jestResult.isSucceeded()) { LOG.info("Successfully created index template {}", templateName); } }
public void deleteIndexTemplate(IndexSet indexSet) { final String templateName = indexSet.getConfig().indexTemplateName(); final JestResult result = JestUtils.execute(jestClient, new DeleteTemplate.Builder(templateName).build(), () -> "Unable to delete the Graylog index template " + templateName); if (result.isSucceeded()) { LOG.info("Successfully deleted index template {}", templateName); } }
private void createTemplates(Map<String, Map<String, Object>> templates) throws IOException { for (Map.Entry<String, Map<String, Object>> template : templates.entrySet()) { final String templateName = template.getKey(); final PutTemplate putTemplate = new PutTemplate.Builder(templateName, template.getValue()).build(); final JestResult result = client.execute(putTemplate); if (!result.isSucceeded()) { throw new IllegalStateException("Error while creating template \"" + templateName + "\": " + result.getErrorMessage()); } } }
private void deleteTemplates(Set<String> templates) throws IOException { for (String template : templates) { final DeleteTemplate deleteTemplate = new DeleteTemplate.Builder(template).build(); final JestResult result = client.execute(deleteTemplate); if (!result.isSucceeded()) { throw new IllegalStateException("Error while deleting template \"" + template + "\": " + result.getErrorMessage()); } } }
@Override public DeleteTemplate build() { return new DeleteTemplate(this); } }
@Override public PutTemplate build() { return new PutTemplate(this); } }
@Override public GetTemplate build() { return new GetTemplate(this); } }
private void doInitialize() throws IOException { // Retrieve the server version final Version version = getServerVersion(); // Load the appropriate template final String template = templateLoader.load(version, templateLocation); // Post it to elastic final PutTemplate putTemplate = new PutTemplate.Builder(templateName, template).build(); final JestResult result = client.execute(putTemplate); if (!result.isSucceeded()) { // In case the template could not be created, we bail throw new IllegalStateException("Template '" + templateName + "' could not be persisted. Reason: " + result.getErrorMessage()); } }
public void deleteIndexTemplate(IndexSet indexSet) { final String templateName = indexSet.getConfig().indexTemplateName(); final JestResult result = JestUtils.execute(jestClient, new DeleteTemplate.Builder(templateName).build(), () -> "Unable to delete the Graylog index template " + templateName); if (result.isSucceeded()) { LOG.info("Successfully deleted index template {}", templateName); } }
@Override public DeleteTemplate build() { return new DeleteTemplate(this); } }
@Override public PutTemplate build() { return new PutTemplate(this); } }
@Override public GetTemplate build() { return new GetTemplate(this); } }
private void doInitialize() throws IOException { // Retrieve the server version final Version version = getServerVersion(); // Load the appropriate template final String template = templateLoader.load(version, templateLocation); // Post it to elastic final PutTemplate putTemplate = new PutTemplate.Builder(templateName, template).build(); final JestResult result = client.execute(putTemplate); if (!result.isSucceeded()) { // In case the template could not be created, we bail throw new IllegalStateException("Template '" + templateName + "' could not be persisted. Reason: " + result.getErrorMessage()); } }
@Override public void execute(IndexTemplate indexTemplate) { TemplateAction templateAction = new PutTemplate.Builder(indexTemplate.getName(), indexTemplate.getSource()).build(); try { JestResult result = createClient().execute(templateAction); if (!result.isSucceeded()) { throw new ConfigurationException("IndexTemplate not added: " + result.getErrorMessage()); } } catch (IOException e) { throw new ConfigurationException("IndexTemplate not added: " + e.getMessage()); } }