use of org.neo4j.kernel.impl.api.index.IndexingService in project neo4j by neo4j.
the class IntegrityValidatorTest method deletingNodeWithRelationshipsIsNotAllowed.
@Test
public void deletingNodeWithRelationshipsIsNotAllowed() throws Exception {
// Given
NeoStores store = mock(NeoStores.class);
IndexingService indexes = mock(IndexingService.class);
IntegrityValidator validator = new IntegrityValidator(store, indexes);
NodeRecord record = new NodeRecord(1L, false, 1L, -1L);
record.setInUse(false);
// When
try {
validator.validateNodeRecord(record);
fail("Should have thrown integrity error.");
} catch (Exception e) {
// good
}
}
use of org.neo4j.kernel.impl.api.index.IndexingService in project neo4j by neo4j.
the class IntegrityValidatorTest method transactionsStartedBeforeAConstraintWasCreatedAreDisallowed.
@Test
public void transactionsStartedBeforeAConstraintWasCreatedAreDisallowed() throws Exception {
// Given
NeoStores store = mock(NeoStores.class);
MetaDataStore metaDataStore = mock(MetaDataStore.class);
when(store.getMetaDataStore()).thenReturn(metaDataStore);
IndexingService indexes = mock(IndexingService.class);
when(metaDataStore.getLatestConstraintIntroducingTx()).thenReturn(10L);
IntegrityValidator validator = new IntegrityValidator(store, indexes);
// When
try {
validator.validateTransactionStartKnowledge(1);
fail("Should have thrown integrity error.");
} catch (Exception e) {
// good
}
}
use of org.neo4j.kernel.impl.api.index.IndexingService in project neo4j by neo4j.
the class NeoStoreFileListingTest method shouldCloseIndexAndLabelScanSnapshots.
@Test
public void shouldCloseIndexAndLabelScanSnapshots() throws Exception {
// Given
LabelScanStore labelScanStore = mock(LabelScanStore.class);
IndexingService indexingService = mock(IndexingService.class);
LegacyIndexProviderLookup legacyIndexes = mock(LegacyIndexProviderLookup.class);
when(legacyIndexes.all()).thenReturn(Collections.emptyList());
File storeDir = mock(File.class);
filesInStoreDirAre(storeDir, STANDARD_STORE_DIR_FILES, STANDARD_STORE_DIR_DIRECTORIES);
StorageEngine storageEngine = mock(StorageEngine.class);
NeoStoreFileListing fileListing = new NeoStoreFileListing(storeDir, labelScanStore, indexingService, legacyIndexes, storageEngine);
ResourceIterator<File> scanSnapshot = scanStoreFilesAre(labelScanStore, new String[] { "blah/scan.store", "scan.more" });
ResourceIterator<File> indexSnapshot = indexFilesAre(indexingService, new String[] { "schema/index/my.index" });
ResourceIterator<StoreFileMetadata> result = fileListing.listStoreFiles(false);
// When
result.close();
// Then
verify(scanSnapshot).close();
verify(indexSnapshot).close();
}
use of org.neo4j.kernel.impl.api.index.IndexingService 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.IndexingService in project neo4j by neo4j.
the class IndexSamplingManagerBeanTest method setup.
@Before
public void setup() {
dataSource = mock(NeoStoreDataSource.class);
storeReadLayer = mock(StoreReadLayer.class);
indexingService = mock(IndexingService.class);
when(dataSource.getStoreLayer()).thenReturn(storeReadLayer);
when(storeReadLayer.labelGetForName(EXISTING_LABEL)).thenReturn(LABEL_ID);
when(storeReadLayer.propertyKeyGetForName(EXISTING_PROPERTY)).thenReturn(PROPERTY_ID);
when(storeReadLayer.propertyKeyGetForName(NON_EXISTING_PROPERTY)).thenReturn(-1);
when(storeReadLayer.labelGetForName(NON_EXISTING_LABEL)).thenReturn(-1);
DependencyResolver resolver = mock(DependencyResolver.class);
when(resolver.resolveDependency(IndexingService.class)).thenReturn(indexingService);
when(dataSource.getDependencyResolver()).thenReturn(resolver);
}
Aggregations