private void deleteIndexesContainingArrayValues( File storeDir, PageCache pageCache, SchemaIndexProvider schemaIndexProvider) throws IOException { File indexRoot = getRootDirectory(storeDir, schemaIndexProvider.getProviderDescriptor().getKey()); IndexSamplingConfig samplingConfig = new IndexSamplingConfig(new Config()); List<File> indexesToBeDeleted = new ArrayList<>(); try (SchemaStore schema = schemaStoreProvider.provide(storeDir, pageCache)) { Iterator<SchemaRule> rules = schema.loadAllSchemaRules(); while (rules.hasNext()) { SchemaRule rule = rules.next(); IndexConfiguration indexConfig = new IndexConfiguration(rule.getKind() == UNIQUENESS_CONSTRAINT); try (IndexAccessor accessor = schemaIndexProvider.getOnlineAccessor(rule.getId(), indexConfig, samplingConfig)) { try (IndexReader reader = accessor.newReader()) { if (reader.valueTypesInIndex().contains(Array.class)) { indexesToBeDeleted.add(new File(indexRoot, "" + rule.getId())); } } } } } for (File index : indexesToBeDeleted) { fileSystem.deleteRecursively(index); } }
@Test public void shouldLogIndexStateOnStart() throws Exception { // given TestLogger logger = new TestLogger(); SchemaIndexProvider provider = mock(SchemaIndexProvider.class); when(provider.getProviderDescriptor()).thenReturn(PROVIDER_DESCRIPTOR); SchemaIndexProviderMap providerMap = new DefaultSchemaIndexProviderMap(provider); TokenNameLookup mockLookup = mock(TokenNameLookup.class); IndexingService indexingService = new IndexingService( mock(JobScheduler.class), providerMap, mock(IndexStoreView.class), mockLookup, mock(UpdateableSchemaState.class), mockLogging(logger)); IndexRule onlineIndex = indexRule(1, 1, 1, PROVIDER_DESCRIPTOR); IndexRule populatingIndex = indexRule(2, 1, 2, PROVIDER_DESCRIPTOR); IndexRule failedIndex = indexRule(3, 2, 2, PROVIDER_DESCRIPTOR); when(provider.getInitialState(onlineIndex.getId())).thenReturn(ONLINE); when(provider.getInitialState(populatingIndex.getId())) .thenReturn(InternalIndexState.POPULATING); when(provider.getInitialState(failedIndex.getId())).thenReturn(InternalIndexState.FAILED); indexingService.initIndexes(asList(onlineIndex, populatingIndex, failedIndex).iterator()); when(mockLookup.labelGetName(1)).thenReturn("LabelOne"); when(mockLookup.labelGetName(2)).thenReturn("LabelTwo"); when(mockLookup.propertyKeyGetName(1)).thenReturn("propertyOne"); when(mockLookup.propertyKeyGetName(2)).thenReturn("propertyTwo"); logger.clear(); // when indexingService.start(); // then verify(provider).getPopulationFailure(3); logger.assertAtLeastOnce( info("IndexingService.start: index on :LabelOne(propertyOne) is ONLINE")); logger.assertAtLeastOnce( info("IndexingService.start: index on :LabelOne(propertyTwo) is POPULATING")); logger.assertAtLeastOnce( info("IndexingService.start: index on :LabelTwo(propertyTwo) is FAILED")); }
private IndexingService newIndexingServiceWithMockedDependencies( IndexPopulator populator, IndexAccessor accessor, DataUpdates data) throws IOException { StringLogger logger = mock(StringLogger.class); indexProvider = mock(SchemaIndexProvider.class); IndexStoreView storeView = mock(IndexStoreView.class); UpdateableSchemaState schemaState = mock(UpdateableSchemaState.class); when(indexProvider.getProviderDescriptor()).thenReturn(PROVIDER_DESCRIPTOR); when(indexProvider.getPopulator(anyLong(), any(IndexConfiguration.class))) .thenReturn(populator); data.getsProcessedByStoreScanFrom(storeView); when(indexProvider.getOnlineAccessor(anyLong(), any(IndexConfiguration.class))) .thenReturn(accessor); return life.add( new IndexingService( life.add(new Neo4jJobScheduler(logger)), new DefaultSchemaIndexProviderMap(indexProvider), storeView, mock(TokenNameLookup.class), schemaState, mockLogging(logger))); }