Search in sources :

Example 6 with IndexManagementConfig

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);
}
Also used : RotationStrategy(org.graylog2.plugin.indexer.rotation.RotationStrategy) RotationStrategyConfig(org.graylog2.plugin.indexer.rotation.RotationStrategyConfig) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) IndexManagementConfig(org.graylog2.indexer.management.IndexManagementConfig) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 7 with IndexManagementConfig

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;
}
Also used : RetentionStrategyConfig(org.graylog2.plugin.indexer.retention.RetentionStrategyConfig) RetentionStrategy(org.graylog2.plugin.indexer.retention.RetentionStrategy)

Example 8 with IndexManagementConfig

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);
}
Also used : NoopRetentionStrategy(org.graylog2.indexer.retention.strategies.NoopRetentionStrategy) NoopRetentionStrategyConfig(org.graylog2.indexer.retention.strategies.NoopRetentionStrategyConfig) RetentionStrategyConfig(org.graylog2.plugin.indexer.retention.RetentionStrategyConfig) RetentionStrategy(org.graylog2.plugin.indexer.retention.RetentionStrategy) NoopRetentionStrategy(org.graylog2.indexer.retention.strategies.NoopRetentionStrategy) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) IndexManagementConfig(org.graylog2.indexer.management.IndexManagementConfig) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 9 with IndexManagementConfig

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;
}
Also used : NotFoundException(javax.ws.rs.NotFoundException) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) IndexManagementConfig(org.graylog2.indexer.management.IndexManagementConfig) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) AuditEvent(org.graylog2.audit.jersey.AuditEvent) PUT(javax.ws.rs.PUT)

Aggregations

IndexManagementConfig (org.graylog2.indexer.management.IndexManagementConfig)7 Timed (com.codahale.metrics.annotation.Timed)4 ApiOperation (io.swagger.annotations.ApiOperation)4 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)4 Path (javax.ws.rs.Path)4 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 NotFoundException (javax.ws.rs.NotFoundException)2 PUT (javax.ws.rs.PUT)2 AuditEvent (org.graylog2.audit.jersey.AuditEvent)2 DefaultIndexSetConfig (org.graylog2.indexer.indexset.DefaultIndexSetConfig)2 IndexSetConfig (org.graylog2.indexer.indexset.IndexSetConfig)2 RetentionStrategy (org.graylog2.plugin.indexer.retention.RetentionStrategy)2 RetentionStrategyConfig (org.graylog2.plugin.indexer.retention.RetentionStrategyConfig)2 RotationStrategy (org.graylog2.plugin.indexer.rotation.RotationStrategy)2 RotationStrategyConfig (org.graylog2.plugin.indexer.rotation.RotationStrategyConfig)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 DefaultIndexSetCreated (org.graylog2.indexer.indexset.DefaultIndexSetCreated)1 ClosingRetentionStrategyConfig (org.graylog2.indexer.retention.strategies.ClosingRetentionStrategyConfig)1 DeletionRetentionStrategyConfig (org.graylog2.indexer.retention.strategies.DeletionRetentionStrategyConfig)1