use of org.graylog2.indexer.management.IndexManagementConfig in project graylog2-server by Graylog2.
the class RotationStrategyResource method config.
@GET
@Path("config")
@Timed
@ApiOperation(value = "Configuration of the current rotation strategy", notes = "This resource returns the configuration of the currently used rotation strategy.")
public RotationStrategySummary config() {
final IndexManagementConfig indexManagementConfig = clusterConfigService.get(IndexManagementConfig.class);
if (indexManagementConfig == null) {
throw new InternalServerErrorException("Couldn't retrieve index management configuration");
}
final String strategyName = indexManagementConfig.rotationStrategy();
final Provider<RotationStrategy> provider = rotationStrategies.get(strategyName);
if (provider == null) {
throw new InternalServerErrorException("Couldn't retrieve rotation strategy provider");
}
final RotationStrategy rotationStrategy = provider.get();
@SuppressWarnings("unchecked") final Class<RotationStrategyConfig> configClass = (Class<RotationStrategyConfig>) rotationStrategy.configurationClass();
final RotationStrategyConfig config = clusterConfigService.get(configClass);
return RotationStrategySummary.create(strategyName, config);
}
use of org.graylog2.indexer.management.IndexManagementConfig in project graylog2-server by Graylog2.
the class V20161116172100_DefaultIndexSetMigration method getRetentionStrategyConfig.
private RetentionStrategyConfig getRetentionStrategyConfig(IndexManagementConfig indexManagementConfig) {
final String strategyName = indexManagementConfig.retentionStrategy();
final Provider<RetentionStrategy> provider = retentionStrategies.get(strategyName);
checkState(provider != null, "Couldn't retrieve retention strategy provider for <" + strategyName + ">");
final RetentionStrategy retentionStrategy = provider.get();
@SuppressWarnings("unchecked") final Class<RetentionStrategyConfig> configClass = (Class<RetentionStrategyConfig>) retentionStrategy.configurationClass();
final RetentionStrategyConfig retentionStrategyConfig = clusterConfigService.get(configClass);
checkState(retentionStrategyConfig != null, "Couldn't retrieve retention strategy config for <" + strategyName + ">");
return retentionStrategyConfig;
}
use of org.graylog2.indexer.management.IndexManagementConfig in project graylog2-server by Graylog2.
the class RetentionStrategyResource method config.
@GET
@Path("config")
@Timed
@ApiOperation(value = "Configuration of the current retention strategy", notes = "This resource returns the configuration of the currently used retention strategy.")
public RetentionStrategySummary config() {
final IndexManagementConfig indexManagementConfig = clusterConfigService.get(IndexManagementConfig.class);
if (indexManagementConfig == null) {
throw new InternalServerErrorException("Couldn't retrieve index management configuration");
}
final String strategyName = indexManagementConfig.retentionStrategy();
final Provider<RetentionStrategy> provider = retentionStrategies.get(strategyName);
if (provider == null) {
LOG.error("Couldn't retrieve retention strategy provider for {}. Returning no-op strategy config.", strategyName);
return RetentionStrategySummary.create(NoopRetentionStrategy.class.getCanonicalName(), NoopRetentionStrategyConfig.createDefault());
}
final RetentionStrategy retentionStrategy = provider.get();
@SuppressWarnings("unchecked") final Class<RetentionStrategyConfig> configClass = (Class<RetentionStrategyConfig>) retentionStrategy.configurationClass();
final RetentionStrategyConfig config = clusterConfigService.get(configClass);
return RetentionStrategySummary.create(strategyName, config);
}
use of org.graylog2.indexer.management.IndexManagementConfig in project graylog2-server by Graylog2.
the class RetentionStrategyResource method config.
@PUT
@Path("config")
@Consumes(MediaType.APPLICATION_JSON)
@Timed
@ApiOperation(value = "Configuration of the current retention strategy", notes = "This resource stores the configuration of the currently used retention strategy.")
@AuditEvent(type = AuditEventTypes.ES_INDEX_RETENTION_STRATEGY_UPDATE)
public RetentionStrategySummary config(@ApiParam(value = "The description of the retention strategy and its configuration", required = true) @Valid @NotNull RetentionStrategySummary retentionStrategySummary) {
if (!retentionStrategies.containsKey(retentionStrategySummary.strategy())) {
throw new NotFoundException("Couldn't find retention strategy for given type " + retentionStrategySummary.strategy());
}
final IndexManagementConfig oldConfig = clusterConfigService.get(IndexManagementConfig.class);
if (oldConfig == null) {
throw new InternalServerErrorException("Couldn't retrieve index management configuration");
}
final IndexManagementConfig indexManagementConfig = IndexManagementConfig.create(oldConfig.rotationStrategy(), retentionStrategySummary.strategy());
clusterConfigService.write(retentionStrategySummary.config());
clusterConfigService.write(indexManagementConfig);
return retentionStrategySummary;
}
Aggregations