use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class ExposedConfigurationTest method testSerialization.
@Test
public void testSerialization() throws Exception {
final Configuration configuration = new Configuration();
final ExposedConfiguration c = ExposedConfiguration.create(configuration);
final String json = objectMapper.writeValueAsString(c);
assertThat((int) JsonPath.read(json, "$.inputbuffer_processors")).isEqualTo(c.inputBufferProcessors());
assertThat((int) JsonPath.read(json, "$.processbuffer_processors")).isEqualTo(c.processBufferProcessors());
assertThat((int) JsonPath.read(json, "$.outputbuffer_processors")).isEqualTo(c.outputBufferProcessors());
assertThat((String) JsonPath.read(json, "$.processor_wait_strategy")).isEqualTo(c.processorWaitStrategy());
assertThat((String) JsonPath.read(json, "$.inputbuffer_wait_strategy")).isEqualTo(c.inputBufferWaitStrategy());
assertThat((int) JsonPath.read(json, "$.inputbuffer_ring_size")).isEqualTo(c.inputBufferRingSize());
assertThat((int) JsonPath.read(json, "$.ring_size")).isEqualTo(c.ringSize());
assertThat((String) JsonPath.read(json, "$.plugin_dir")).isEqualTo(c.pluginDir());
assertThat((String) JsonPath.read(json, "$.node_id_file")).isEqualTo(c.nodeIdFile());
assertThat((boolean) JsonPath.read(json, "$.allow_highlighting")).isEqualTo(c.allowHighlighting());
assertThat((boolean) JsonPath.read(json, "$.allow_leading_wildcard_searches")).isEqualTo(c.allowLeadingWildcardSearches());
assertThat((int) JsonPath.read(json, "$.stream_processing_timeout")).isEqualTo((int) c.streamProcessingTimeout());
assertThat((int) JsonPath.read(json, "$.stream_processing_max_faults")).isEqualTo(c.streamProcessingMaxFaults());
assertThat((int) JsonPath.read(json, "$.output_module_timeout")).isEqualTo((int) c.outputModuleTimeout());
assertThat((int) JsonPath.read(json, "$.stale_master_timeout")).isEqualTo(c.staleMasterTimeout());
assertThat((String) JsonPath.read(json, "$.gc_warning_threshold")).isEqualTo(c.gcWarningThreshold());
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class MessageProcessorsResource method config.
@GET
@Timed
@ApiOperation(value = "Get message processor configuration")
@Path("config")
public MessageProcessorsConfigWithDescriptors config() {
checkPermission(RestPermissions.CLUSTER_CONFIG_ENTRY_READ);
final MessageProcessorsConfig config = clusterConfigService.getOrDefault(MessageProcessorsConfig.class, MessageProcessorsConfig.defaultConfig());
return MessageProcessorsConfigWithDescriptors.fromConfig(config.withProcessors(processorClassNames), processorDescriptors);
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class IndexSetsResource method update.
@PUT
@Path("{id}")
@Timed
@ApiOperation(value = "Update index set")
@AuditEvent(type = AuditEventTypes.INDEX_SET_UPDATE)
@ApiResponses(value = { @ApiResponse(code = 403, message = "Unauthorized"), @ApiResponse(code = 409, message = "Mismatch of IDs in URI path and payload") })
public IndexSetSummary update(@ApiParam(name = "id", required = true) @PathParam("id") String id, @ApiParam(name = "Index set configuration", required = true) @Valid @NotNull IndexSetUpdateRequest updateRequest) {
checkPermission(RestPermissions.INDEXSETS_EDIT, id);
final IndexSetConfig oldConfig = indexSetService.get(id).orElseThrow(() -> new NotFoundException("Index set <" + id + "> not found"));
final IndexSetConfig defaultIndexSet = indexSetService.getDefault();
final boolean isDefaultSet = oldConfig.equals(defaultIndexSet);
if (isDefaultSet && !updateRequest.isWritable()) {
throw new ClientErrorException("Default index set must be writable.", Response.Status.CONFLICT);
}
final IndexSetConfig savedObject = indexSetService.save(updateRequest.toIndexSetConfig(id, oldConfig));
return IndexSetSummary.fromIndexSetConfig(savedObject, isDefaultSet);
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class JsonTesterResource method testJsonExtractor.
private JsonTesterResponse testJsonExtractor(String testString, boolean flatten, String listSeparator, String keySeparator, String kvSeparator, boolean replaceKeyWhitespace, String keyWhitespaceReplacement, String keyPrefix) {
final Map<String, Object> config = ImmutableMap.<String, Object>builder().put("flatten", flatten).put("list_separator", listSeparator).put("key_separator", keySeparator).put("kv_separator", kvSeparator).put("replace_key_whitespace", replaceKeyWhitespace).put("key_whitespace_replacement", keyWhitespaceReplacement).put("key_prefix", keyPrefix).build();
final JsonExtractor extractor;
try {
extractor = new JsonExtractor(new MetricRegistry(), "test", "Test", 0L, Extractor.CursorStrategy.COPY, "test", "test", config, getCurrentUser().getName(), Collections.<Converter>emptyList(), Extractor.ConditionType.NONE, "");
} catch (Extractor.ReservedFieldException e) {
throw new BadRequestException("Trying to overwrite a reserved message field", e);
} catch (ConfigurationException e) {
throw new BadRequestException("Invalid extractor configuration", e);
}
final Map<String, Object> result = extractor.extractJson(testString);
return JsonTesterResponse.create(result, flatten, listSeparator, keySeparator, kvSeparator, testString);
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class RegexReplaceTesterResource method testRegexReplaceExtractor.
private RegexReplaceTesterResponse testRegexReplaceExtractor(String example, String regex, String replacement, boolean replaceAll) {
final Map<String, Object> config = ImmutableMap.<String, Object>of("regex", regex, "replacement", replacement, "replace_all", replaceAll);
final RegexReplaceExtractor extractor;
try {
extractor = new RegexReplaceExtractor(new MetricRegistry(), "test", "Test", 0L, Extractor.CursorStrategy.COPY, "test", "test", config, getCurrentUser().getName(), Collections.<Converter>emptyList(), Extractor.ConditionType.NONE, "");
} catch (Extractor.ReservedFieldException e) {
throw new BadRequestException("Trying to overwrite a reserved message field", e);
} catch (ConfigurationException e) {
throw new BadRequestException("Invalid extractor configuration", e);
}
final Extractor.Result result = extractor.runExtractor(example);
final RegexReplaceTesterResponse.Match match = result == null ? null : RegexReplaceTesterResponse.Match.create(String.valueOf(result.getValue()), result.getBeginIndex(), result.getEndIndex());
return RegexReplaceTesterResponse.create(result != null, match, regex, replacement, replaceAll, example);
}
Aggregations