//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void dropShouldDeleteEntireIndexFolder()
        public virtual 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);
            StoreIndexDescriptor descriptor = IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(1, 1)).withId(indexId);
            IndexSpecificSpaceFillingCurveSettingsCache spatialSettings = mock(typeof(IndexSpecificSpaceFillingCurveSettingsCache));
            PageCache             pageCache        = Storage.pageCache();
            FileSystemAbstraction fs               = Storage.fileSystem();
            File          indexFile                = new File(indexDirectory, "my-index");
            GenericLayout layout                   = new GenericLayout(1, spatialSettings);
            RecoveryCleanupWorkCollector immediate = immediate();
            IndexDropAction             dropAction = new FileSystemIndexDropAction(fs, directoryStructure);
            GenericNativeIndexPopulator populator  = new GenericNativeIndexPopulator(pageCache, fs, indexFile, layout, EMPTY, descriptor, spatialSettings, directoryStructure, mock(typeof(SpaceFillingCurveConfiguration)), dropAction, false);

            populator.Create();

            // when
            assertTrue(fs.ListFiles(indexDirectory).Length > 0);
            populator.Drop();

            // then
            assertFalse(fs.FileExists(indexDirectory));
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void schemaAndLabelIndexesRemovedAfterSuccessfulMigration() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SchemaAndLabelIndexesRemovedAfterSuccessfulMigration()
        {
            IndexDirectoryStructure directoryStructure = mock(typeof(IndexDirectoryStructure));
            File indexProviderRootDirectory            = _databaseLayout.file("just-some-directory");

            when(directoryStructure.RootDirectory()).thenReturn(indexProviderRootDirectory);
            when(_indexProvider.directoryStructure()).thenReturn(directoryStructure);
            when(_indexProvider.ProviderDescriptor).thenReturn(new IndexProviderDescriptor("key", "version"));

            _migrator.migrate(_databaseLayout, _migrationLayout, _progressReporter, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION);

            _migrator.moveMigratedFiles(_migrationLayout, _databaseLayout, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION);

            verify(_fs).deleteRecursively(indexProviderRootDirectory);
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailToValidateConstraintsIfUnderlyingIndexIsFailed() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailToValidateConstraintsIfUnderlyingIndexIsFailed()
        {
            // given a perfectly normal constraint
            File dir = Directory.databaseDir();
            GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(dir);

            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.schema().constraintFor(label("Label1")).assertPropertyIsUnique("key1").create();
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }

            // Remove the indexes offline and start up with an index provider which reports FAILED as initial state. An ordeal, I know right...
            FileUtils.deleteRecursively(IndexDirectoryStructure.baseSchemaIndexFolder(dir));
            db = (new TestGraphDatabaseFactory()).removeKernelExtensions(INDEX_PROVIDERS_FILTER).addKernelExtension(new FailingGenericNativeIndexProviderFactory(INITIAL_STATE)).newEmbeddedDatabase(dir);
            // when
            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.createNode(label("Label1")).setProperty("key1", "value1");
                    fail("expected exception");
                }
            }
            // then
            catch (ConstraintViolationException e)
            {
                assertThat(e.InnerException, instanceOf(typeof(UnableToValidateConstraintException)));
                assertThat(e.InnerException.InnerException.Message, allOf(containsString("The index is in a failed state:"), containsString(INITIAL_STATE_FAILURE_MESSAGE)));
            }
            finally
            {
                Db.shutdown();
            }
        }
Exemplo n.º 4
0
 public IndexDirectoryStructureAnonymousInnerClass(Org.Neo4j.Kernel.Api.Index.IndexDirectoryStructure parentStructure)
 {
     this._parentStructure = parentStructure;
 }
Exemplo n.º 5
0
 public static IndexDirectoryStructure.Factory DefaultDirectoryStructure(File storeDir)
 {
     return(IndexDirectoryStructure.directoriesByProviderKey(storeDir));
 }
        private static IndexDirectoryStructure.Factory SubProviderDirectoryStructure(File storeDir)
        {
            IndexDirectoryStructure parentDirectoryStructure = directoriesByProvider(storeDir).forProvider(Descriptor);

            return(directoriesBySubProvider(parentDirectoryStructure));
        }
Exemplo n.º 7
0
 public IndexStorageFactory(DirectoryFactory dirFactory, FileSystemAbstraction fileSystem, IndexDirectoryStructure structure)
 {
     this._dirFactory = dirFactory;
     this._fileSystem = fileSystem;
     this._structure  = structure;
 }
Exemplo n.º 8
0
 public FileSystemIndexDropAction(FileSystemAbstraction fs, IndexDirectoryStructure directoryStructure)
 {
     this._fs = fs;
     this._directoryStructure = directoryStructure;
 }