Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove disable_index_range_calculation setting #1411

Merged
merged 2 commits into from Sep 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -114,9 +114,6 @@ public class ElasticsearchConfiguration {
@Parameter(value = "disable_index_optimization")
private boolean disableIndexOptimization = false;

@Parameter(value = "disable_index_range_calculation")
private boolean disableIndexRangeCalculation = true;

@Parameter(value = "index_optimization_max_num_segments", validator = PositiveIntegerValidator.class)
private int indexOptimizationMaxNumSegments = 1;

Expand Down Expand Up @@ -243,10 +240,6 @@ public boolean isDisableIndexOptimization() {
return disableIndexOptimization;
}

public boolean isDisableIndexRangeCalculation() {
return disableIndexRangeCalculation;
}

public String getPathData() {
return pathData;
}
Expand Down
23 changes: 2 additions & 21 deletions graylog2-server/src/main/java/org/graylog2/indexer/Deflector.java
Expand Up @@ -55,28 +55,23 @@ public class Deflector { // extends Ablenkblech

private final SystemJobManager systemJobManager;
private final ActivityWriter activityWriter;
private final RebuildIndexRangesJob.Factory rebuildIndexRangesJobFactory;
private final CreateNewSingleIndexRangeJob.Factory createNewSingleIndexRangeJobFactory;
private final String indexPrefix;
private final String deflectorName;
private final Indices indices;
private final ElasticsearchConfiguration configuration;
private final SetIndexReadOnlyJob.Factory indexReadOnlyJobFactory;

@Inject
public Deflector(final SystemJobManager systemJobManager,
final ElasticsearchConfiguration configuration,
final ActivityWriter activityWriter,
final RebuildIndexRangesJob.Factory rebuildIndexRangesJobFactory,
final SetIndexReadOnlyJob.Factory indexReadOnlyJobFactory,
final CreateNewSingleIndexRangeJob.Factory createNewSingleIndexRangeJobFactory,
final Indices indices) {
this.configuration = configuration;
this.indexPrefix = configuration.getIndexPrefix();

this.systemJobManager = systemJobManager;
this.activityWriter = activityWriter;
this.rebuildIndexRangesJobFactory = rebuildIndexRangesJobFactory;
this.indexReadOnlyJobFactory = indexReadOnlyJobFactory;
this.createNewSingleIndexRangeJobFactory = createNewSingleIndexRangeJobFactory;

Expand Down Expand Up @@ -156,6 +151,7 @@ public void cycle() {
} else {
// Re-pointing from existing old index to the new one.
pointTo(newTarget, oldTarget);
addSingleIndexRanges(oldTarget);

// perform these steps after a delay, so we don't race with indexing into the alias
// it can happen that an index request still writes to the old deflector target, while we cycled it above.
Expand All @@ -170,11 +166,7 @@ public void cycle() {
activity.setMessage("Cycled deflector from <" + oldTarget + "> to <" + newTarget + ">");
}

if (configuration.isDisableIndexRangeCalculation() && oldTargetNumber != -1) {
addSingleIndexRanges(oldTarget);
addSingleIndexRanges(newTarget);
} else
updateIndexRanges();
addSingleIndexRanges(newTarget);

LOG.info("Done!");

Expand Down Expand Up @@ -262,17 +254,6 @@ public void pointTo(final String newIndex) {
indices.cycleAlias(getName(), newIndex);
}

private void updateIndexRanges() {
// Re-calculate index ranges.
try {
systemJobManager.submit(rebuildIndexRangesJobFactory.create(this));
} catch (SystemJobConcurrencyException e) {
final String msg = "Could not re-calculate index ranges after cycling deflector: Maximum concurrency of job is reached.";
activityWriter.write(new Activity(msg, Deflector.class));
LOG.error(msg, e);
}
}

private void addSingleIndexRanges(String indexName) {
try {
systemJobManager.submit(createNewSingleIndexRangeJobFactory.create(this, indexName));
Expand Down
Expand Up @@ -24,7 +24,6 @@
import org.graylog2.configuration.ElasticsearchConfiguration;
import org.graylog2.indexer.indices.Indices;
import org.graylog2.indexer.ranges.CreateNewSingleIndexRangeJob;
import org.graylog2.indexer.ranges.RebuildIndexRangesJob;
import org.graylog2.system.activities.SystemMessageActivityWriter;
import org.graylog2.system.jobs.SystemJobManager;
import org.junit.Before;
Expand All @@ -50,7 +49,6 @@ public void setUp() {
mock(SystemJobManager.class),
new ElasticsearchConfiguration(),
mock(SystemMessageActivityWriter.class),
mock(RebuildIndexRangesJob.Factory.class),
mock(SetIndexReadOnlyJob.Factory.class),
mock(CreateNewSingleIndexRangeJob.Factory.class),
mock(Indices.class));
Expand Down Expand Up @@ -81,7 +79,6 @@ public void testBuildIndexName() {
Deflector d = new Deflector(mock(SystemJobManager.class),
mock(ElasticsearchConfiguration.class),
mock(SystemMessageActivityWriter.class),
mock(RebuildIndexRangesJob.Factory.class),
mock(SetIndexReadOnlyJob.Factory.class),
mock(CreateNewSingleIndexRangeJob.Factory.class),
mock(Indices.class));
Expand All @@ -101,7 +98,6 @@ public void nullIndexerDoesNotThrow() {
Deflector d = new Deflector(mock(SystemJobManager.class),
mock(ElasticsearchConfiguration.class),
mock(SystemMessageActivityWriter.class),
mock(RebuildIndexRangesJob.Factory.class),
mock(SetIndexReadOnlyJob.Factory.class),
mock(CreateNewSingleIndexRangeJob.Factory.class),
mock(Indices.class));
Expand All @@ -116,7 +112,6 @@ public void nullIndexerDoesNotThrowOnIndexName() {
Deflector d = new Deflector(mock(SystemJobManager.class),
mock(ElasticsearchConfiguration.class),
mock(SystemMessageActivityWriter.class),
mock(RebuildIndexRangesJob.Factory.class),
mock(SetIndexReadOnlyJob.Factory.class),
mock(CreateNewSingleIndexRangeJob.Factory.class),
mock(Indices.class));
Expand Down
Expand Up @@ -87,7 +87,7 @@ public EsIndexRangeServiceTest() {
@Before
public void setUp() throws Exception {
indices = new Indices(client, ELASTICSEARCH_CONFIGURATION, new IndexMapping(client));
final Deflector deflector = new Deflector(null, ELASTICSEARCH_CONFIGURATION, new NullActivityWriter(), null, null, null, indices);
final Deflector deflector = new Deflector(null, ELASTICSEARCH_CONFIGURATION, new NullActivityWriter(), null, null, indices);
indexRangeService = new EsIndexRangeService(client, objectMapper, indices, deflector,
new EventBus("local"), new EventBus("cluster"), new MetricRegistry());
}
Expand Down
8 changes: 0 additions & 8 deletions misc/graylog2.conf
Expand Up @@ -375,14 +375,6 @@ mongodb_threads_allowed_to_block_multiplier = 5
# on heavily used systems with large indices, but it will decrease search performance. The default is 1.
#index_optimization_max_num_segments = 1

# Disable the index range calculation on all open/available indices and only calculate the range for the latest
# index.
# This may speed up index cycling on systems with large indices but it might lead to wrong search results
# in regard to the time range of the messages (i. e. messages within a certain range may not be found) if the indices
# have been modified after Graylog rotated them.
# Default: true
#disable_index_range_calculation = true

# The threshold of the garbage collection runs. If GC runs take longer than this threshold, a system notification
# will be generated to warn the administrator about possible problems with the system. Default is 1 second.
#gc_warning_threshold = 1s
Expand Down