use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingMode in project neo4j by neo4j.
the class IndexProcedures method resampleOutdatedIndexes.
void resampleOutdatedIndexes(long timeOutSeconds) {
long millis = TimeUnit.SECONDS.toMillis(timeOutSeconds);
IndexSamplingMode mode = foregroundRebuildUpdated(millis);
indexingService.triggerIndexSampling(mode);
}
use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingMode in project neo4j by neo4j.
the class BuiltInProceduresIT method prepareForReplanningShouldTriggerIndexesSampling.
@Test
void prepareForReplanningShouldTriggerIndexesSampling() {
// Given
ReplanMonitor monitor = replanMonitor();
// When
try (org.neo4j.graphdb.Transaction transaction = db.beginTx()) {
transaction.execute("CALL db.prepareForReplanning()").close();
transaction.commit();
}
// Then
IndexSamplingMode mode = monitor.samplingMode();
assertNotEquals(IndexSamplingMode.NO_WAIT, mode.millisToWaitForCompletion());
assertThat(mode.millisToWaitForCompletion()).isGreaterThan(0L);
}
use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingMode in project neo4j by neo4j.
the class IndexingServiceTest method shouldLogTriggerSamplingOnAllIndexes.
@Test
void shouldLogTriggerSamplingOnAllIndexes() throws Exception {
// given
IndexingService indexingService = newIndexingServiceWithMockedDependencies(populator, accessor, withData());
IndexSamplingMode mode = backgroundRebuildAll();
// when
indexingService.triggerIndexSampling(mode);
// then
assertThat(internalLogProvider).forLevel(INFO).containsMessages("Manual trigger for sampling all indexes [" + mode + "]");
}
use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingMode in project neo4j by neo4j.
the class Schema method sampleIndexes.
private void sampleIndexes(Label[] labels, String property, boolean sampleAll, boolean forceSample) throws ShellException {
IndexingService indexingService = getServer().getDb().getDependencyResolver().resolveDependency(IndexingService.class);
if (indexingService == null) {
throw new ShellException("Internal error: failed to resolve IndexingService");
}
IndexSamplingMode samplingMode = getSamplingMode(forceSample);
// Trigger sampling for all indices
if (sampleAll) {
indexingService.triggerIndexSampling(samplingMode);
return;
}
validateLabelsAndProperty(labels, property);
Statement statement = getServer().getStatement();
int labelKey = statement.readOperations().labelGetForName(labels[0].name());
int propertyKey = statement.readOperations().propertyKeyGetForName(property);
if (labelKey == -1) {
throw new ShellException("No label associated with '" + labels[0].name() + "' was found");
}
if (propertyKey == -1) {
throw new ShellException("No property associated with '" + property + "' was found");
}
try {
indexingService.triggerIndexSampling(SchemaDescriptorFactory.forLabel(labelKey, propertyKey), samplingMode);
} catch (IndexNotFoundKernelException e) {
throw new ShellException(e.getMessage());
}
}
use of org.neo4j.kernel.impl.api.index.sampling.IndexSamplingMode in project neo4j by neo4j.
the class IndexingServiceTest method shouldLogTriggerSamplingOnAnIndexes.
@Test
void shouldLogTriggerSamplingOnAnIndexes() throws Exception {
// given
long indexId = 0;
IndexSamplingMode mode = backgroundRebuildAll();
IndexPrototype prototype = forSchema(forLabel(0, 1)).withIndexProvider(PROVIDER_DESCRIPTOR).withName("index");
IndexDescriptor index = prototype.materialise(indexId);
when(accessor.newValueReader()).thenReturn(ValueIndexReader.EMPTY);
IndexingService indexingService = newIndexingServiceWithMockedDependencies(populator, accessor, withData(), index);
life.init();
life.start();
// when
indexingService.triggerIndexSampling(index, mode);
// then
String userDescription = index.userDescription(nameLookup);
assertThat(internalLogProvider).forLevel(INFO).containsMessages("Manual trigger for sampling index " + userDescription + " [" + mode + "]");
}
Aggregations