@Test public void dropShouldDeleteEntireIndexFolder() { // given File root = storage.directory().directory( "root" ); IndexDirectoryStructure directoryStructure = IndexDirectoryStructure.directoriesByProvider( root ).forProvider( GenericNativeIndexProvider.DESCRIPTOR ); long indexId = 8; File indexDirectory = directoryStructure.directoryForIndex( indexId ); File indexFile = new File( indexDirectory, "my-index" ); StoreIndexDescriptor descriptor = IndexDescriptorFactory.forSchema( SchemaDescriptorFactory.forLabel( 1, 1 ) ).withId( indexId ); IndexSpecificSpaceFillingCurveSettingsCache spatialSettings = mock( IndexSpecificSpaceFillingCurveSettingsCache.class ); FileSystemAbstraction fs = storage.fileSystem(); GenericNativeIndexAccessor accessor = new GenericNativeIndexAccessor( storage.pageCache(), fs, indexFile, new GenericLayout( 1, spatialSettings ), immediate(), EMPTY, descriptor, spatialSettings, directoryStructure, mock( SpaceFillingCurveConfiguration.class ) ); // when accessor.drop(); // then assertFalse( fs.fileExists( indexDirectory ) ); } }
protected IndexProvider( IndexProviderDescriptor descriptor, IndexDirectoryStructure.Factory directoryStructureFactory ) { this.directoryStructureFactory = directoryStructureFactory; assert descriptor != null; this.providerDescriptor = descriptor; this.directoryStructure = directoryStructureFactory.forProvider( descriptor ); }
@Before public void setup() throws IOException { valueCreatorUtil = createValueCreatorUtil(); indexDescriptor = valueCreatorUtil.indexDescriptor(); layout = createLayout(); indexDirectoryStructure = directoriesByProvider( directory.directory( "root" ) ).forProvider( indexDescriptor.providerDescriptor() ); indexFile = indexDirectoryStructure.directoryForIndex( indexDescriptor.getId() ); fs.mkdirs( indexFile.getParentFile() ); pageCache = pageCacheRule.getPageCache( fs ); }
private void deleteIndexFilesFor( IndexProviderDescriptor descriptor ) { File databaseDirectory = this.databaseLayout.databaseDirectory(); File rootDirectory = subProviderDirectoryStructure( databaseDirectory ).forProvider( descriptor ).rootDirectory(); File[] files = fs.listFiles( rootDirectory ); for ( File indexFile : files ) { fs.deleteFile( indexFile ); } }
public static IndexDirectoryStructure.Factory subProviderDirectoryStructure( File databaseDirectory, IndexProviderDescriptor descriptor ) { IndexDirectoryStructure parentDirectoryStructure = directoriesByProvider( databaseDirectory ).forProvider( descriptor ); return directoriesBySubProvider( parentDirectoryStructure ); } }
private static IndexDirectoryStructure.Factory subProviderDirectoryStructure( File storeDir ) { IndexDirectoryStructure parentDirectoryStructure = directoriesByProvider( storeDir ).forProvider( DESCRIPTOR ); return directoriesBySubProvider( parentDirectoryStructure ); }
@Test public void shouldNotAcceptLuceneFileFromFusionProvider() throws IOException { // given File dir = subProviderDirectoryStructure( storeDir, LUCENE_DESCRTIPTOR ).forProvider( LUCENE_DESCRTIPTOR ).directoryForIndex( 1 ); File file = new File( dir, "some-file" ); createFile( file ); // when boolean accepted = filter.accept( file ); // then assertFalse( accepted ); }
@Test public void shouldNotAcceptFileFromPureLuceneProvider() throws IOException { // given File dir = directoriesByProviderKey( storeDir ).forProvider( LUCENE_DESCRTIPTOR ).directoryForIndex( 1 ); File file = new File( dir, "some-file" ); createFile( file ); // when boolean accepted = filter.accept( file ); // then assertFalse( accepted ); }
@Test public void shouldSeeCorrectDirectoriesForProvider() { assertCorrectDirectories( directoriesByProvider( databaseStoreDir ).forProvider( provider ), path( baseIndexDirectory, provider.getKey() + "-" + provider.getVersion() ), path( baseIndexDirectory, provider.getKey() + "-" + provider.getVersion(), String.valueOf( indexId ) ) ); }
@Before public void setup() { DefaultFileSystemAbstraction fs = this.fs.get(); PageCache pc = pageCacheRule.getPageCache( fs ); File file = directory.file( "index" ); GenericLayout layout = new GenericLayout( 1, indexSettings ); RecoveryCleanupWorkCollector collector = RecoveryCleanupWorkCollector.ignore(); descriptor = TestIndexDescriptorFactory.forLabel( 1, 1 ).withId( 1 ); IndexDirectoryStructure.Factory factory = IndexDirectoryStructure.directoriesByProvider( directory.storeDir() ); IndexDirectoryStructure structure = factory.forProvider( GenericNativeIndexProvider.DESCRIPTOR ); accessor = new GenericNativeIndexAccessor( pc, fs, file, layout, collector, EMPTY, descriptor, indexSettings, structure, new StandardConfiguration() ); }
private void shouldAcceptNativeIndexFileFromFusionProvider( IndexProviderDescriptor descriptor ) throws IOException { // given File dir = subProviderDirectoryStructure( storeDir, descriptor ).forProvider( descriptor ).directoryForIndex( 1 ); File file = new File( dir, "some-file" ); createFile( file ); // when boolean accepted = filter.accept( file ); // then assertTrue( accepted ); }
private PartitionedIndexStorage getIndexStorage() { IndexStorageFactory storageFactory = new IndexStorageFactory( directoryFactory, fileSystem, directoriesByProviderKey( storeDirectory ).forProvider( PROVIDER_DESCRIPTOR ) ); return storageFactory.indexStorageOf( 1 ); }
@Test public void shouldHandleWeirdCharactersInProviderKey() { IndexProviderDescriptor providerWithWeirdName = new IndexProviderDescriptor( "native+lucene", "1.0" ); assertCorrectDirectories( directoriesByProvider( databaseStoreDir ).forProvider( providerWithWeirdName ), path( baseIndexDirectory, "native_lucene-1.0" ), path( baseIndexDirectory, "native_lucene-1.0", String.valueOf( indexId ) ) ); }
protected IndexProvider( IndexProviderDescriptor descriptor, IndexDirectoryStructure.Factory directoryStructureFactory ) { this.directoryStructureFactory = directoryStructureFactory; assert descriptor != null; this.providerDescriptor = descriptor; this.directoryStructure = directoryStructureFactory.forProvider( descriptor ); }
private IndexDirectoryStructure.Factory directory() { File storeDir = rules.directory().databaseDir(); return directoriesBySubProvider( directoriesByProvider( storeDir ).forProvider( PROVIDER ) ); }
@Test public void shouldSeeCorrectDirectoriesForSubProvider() { IndexDirectoryStructure parentStructure = directoriesByProvider( databaseStoreDir ).forProvider( provider ); IndexProviderDescriptor subProvider = new IndexProviderDescriptor( "sub", "0.3" ); assertCorrectDirectories( directoriesBySubProvider( parentStructure ).forProvider( subProvider ), path( baseIndexDirectory, provider.getKey() + "-" + provider.getVersion() ), path( baseIndexDirectory, provider.getKey() + "-" + provider.getVersion(), String.valueOf( indexId ), subProvider.getKey() + "-" + subProvider.getVersion() ) ); }
@Test public void shouldSeeCorrectDirectoriesForProviderKey() { assertCorrectDirectories( directoriesByProviderKey( databaseStoreDir ).forProvider( provider ), path( baseIndexDirectory, provider.getKey() ), path( baseIndexDirectory, provider.getKey(), String.valueOf( indexId ) ) ); }
static IndexDirectoryStructure nativeIndexDirectoryStructure( DatabaseLayout databaseLayout ) { return IndexDirectoryStructure.directoriesByProvider( databaseLayout.databaseDirectory() ).forProvider( GenericNativeIndexProvider.DESCRIPTOR ); } }