internal GenericNativeIndexPopulator(PageCache pageCache, FileSystemAbstraction fs, File storeFile, IndexLayout <GenericKey, NativeIndexValue> layout, IndexProvider.Monitor monitor, StoreIndexDescriptor descriptor, IndexSpecificSpaceFillingCurveSettingsCache spatialSettings, IndexDirectoryStructure directoryStructure, SpaceFillingCurveConfiguration configuration, IndexDropAction dropAction, bool archiveFailedIndex) : base(pageCache, fs, storeFile, layout, monitor, descriptor, new SpaceFillingCurveSettingsWriter(spatialSettings))
 {
     this._spatialSettings    = spatialSettings;
     this._directoryStructure = directoryStructure;
     this._configuration      = configuration;
     this._dropAction         = dropAction;
     this._archiveFailedIndex = archiveFailedIndex;
 }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            ValueCreatorUtil        = CreateValueCreatorUtil();
            IndexDescriptor         = ValueCreatorUtil.indexDescriptor();
            Layout                  = CreateLayout();
            IndexDirectoryStructure = directoriesByProvider(_directory.directory("root")).forProvider(IndexDescriptor.providerDescriptor());
            _indexFile              = IndexDirectoryStructure.directoryForIndex(IndexDescriptor.Id);
            Fs.mkdirs(_indexFile.ParentFile);
            PageCache = _pageCacheRule.getPageCache(Fs);
        }
Example #3
0
 internal BlockBasedIndexPopulator(PageCache pageCache, FileSystemAbstraction fs, File file, IndexLayout <KEY, VALUE> layout, IndexProvider.Monitor monitor, StoreIndexDescriptor descriptor, IndexSpecificSpaceFillingCurveSettingsCache spatialSettings, IndexDirectoryStructure directoryStructure, IndexDropAction dropAction, bool archiveFailedIndex, ByteBufferFactory bufferFactory, int mergeFactor, BlockStorage.Monitor blockStorageMonitor) : base(pageCache, fs, file, layout, monitor, descriptor, new SpaceFillingCurveSettingsWriter(spatialSettings))
 {
     this._directoryStructure  = directoryStructure;
     this._dropAction          = dropAction;
     this._archiveFailedIndex  = archiveFailedIndex;
     this._mergeFactor         = mergeFactor;
     this._blockStorageMonitor = blockStorageMonitor;
     this._scanUpdates         = ThreadLocal.withInitial(this.newThreadLocalBlockStorage);
     this._bufferFactory       = bufferFactory;
 }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("test", "v1");

            _directoryStructure = directoriesByProvider(Storage.directory().databaseDir()).forProvider(providerDescriptor);
            _indexDir           = _directoryStructure.directoryForIndex(_indexDescriptor.Id);
            _indexFile          = new File(_indexDir, "index");
            _fs         = Storage.fileSystem();
            _dropAction = new FileSystemIndexDropAction(_fs, _directoryStructure);
        }
Example #5
0
        internal TemporalIndexFiles(IndexDirectoryStructure directoryStructure, StoreIndexDescriptor descriptor, FileSystemAbstraction fs)
        {
            this._fs = fs;
            File indexDirectory = directoryStructure.DirectoryForIndex(descriptor.Id);

            this._date          = new FileLayout <DateIndexKey>(new File(indexDirectory, "date"), new DateLayout(), ValueGroup.DATE);
            this._localTime     = new FileLayout <LocalTimeIndexKey>(new File(indexDirectory, "localTime"), new LocalTimeLayout(), ValueGroup.LOCAL_TIME);
            this._zonedTime     = new FileLayout <ZonedTimeIndexKey>(new File(indexDirectory, "zonedTime"), new ZonedTimeLayout(), ValueGroup.ZONED_TIME);
            this._localDateTime = new FileLayout <LocalDateTimeIndexKey>(new File(indexDirectory, "localDateTime"), new LocalDateTimeLayout(), ValueGroup.LOCAL_DATE_TIME);
            this._zonedDateTime = new FileLayout <ZonedDateTimeIndexKey>(new File(indexDirectory, "zonedDateTime"), new ZonedDateTimeLayout(), ValueGroup.ZONED_DATE_TIME);
            this._duration      = new FileLayout <DurationIndexKey>(new File(indexDirectory, "duration"), new DurationLayout(), ValueGroup.DURATION);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual 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);
            IndexDropAction dropAction = new FileSystemIndexDropAction(fs, structure);

            _accessor = new GenericNativeIndexAccessor(pc, fs, file, layout, collector, EMPTY, _descriptor, _indexSettings, new StandardConfiguration(), dropAction, false);
        }
Example #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static long[] calculatePageCacheFileSize(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws java.io.IOException
        private static long[] CalculatePageCacheFileSize(DatabaseLayout databaseLayout)
        {
            MutableLong pageCacheTotal = new MutableLong();
            MutableLong luceneTotal    = new MutableLong();

            foreach (StoreType storeType in StoreType.values())
            {
                if (storeType.RecordStore)
                {
                    long length = databaseLayout.file(storeType.DatabaseFile).mapToLong(File.length).sum();
                    pageCacheTotal.add(length);
                }
            }

            Files.walkFileTree(IndexDirectoryStructure.baseSchemaIndexFolder(databaseLayout.DatabaseDirectory()).toPath(), new SimpleFileVisitorAnonymousInnerClass(pageCacheTotal, luceneTotal));
            pageCacheTotal.add(databaseLayout.LabelScanStore().length());
            return(new long[] { pageCacheTotal.longValue(), luceneTotal.longValue() });
        }
Example #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCountAllIndexFiles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldCountAllIndexFiles()
        {
            // Explicit index file
            File explicitIndex = _testDirectory.databaseLayout().file("explicitIndex");

            CreateFileOfSize(explicitIndex, 1);

            IndexImplementation indexImplementation = mock(typeof(IndexImplementation));

            when(indexImplementation.GetIndexImplementationDirectory(any())).thenReturn(explicitIndex);
            when(_explicitIndexProviderLookup.allIndexProviders()).thenReturn(iterable(indexImplementation));

            // Schema index files
            File schemaIndex = _testDirectory.databaseLayout().file("schemaIndex");

            CreateFileOfSize(schemaIndex, 2);
            IndexDirectoryStructure directoryStructure = mock(typeof(IndexDirectoryStructure));

            when(directoryStructure.RootDirectory()).thenReturn(schemaIndex);
            when(_indexProvider.directoryStructure()).thenReturn(directoryStructure);

            File schemaIndex2 = _testDirectory.databaseLayout().file("schemaIndex2");

            CreateFileOfSize(schemaIndex2, 3);
            IndexDirectoryStructure directoryStructure2 = mock(typeof(IndexDirectoryStructure));

            when(directoryStructure2.RootDirectory()).thenReturn(schemaIndex2);
            when(_indexProvider2.directoryStructure()).thenReturn(directoryStructure2);

            // Label scan store
            File labelScan = _testDirectory.databaseLayout().labelScanStore();

            CreateFileOfSize(labelScan, 4);
            when(_labelScanStore.LabelScanStoreFile).thenReturn(labelScan);

            // Count all files
            assertEquals(10, _storeSizeBean.IndexStoreSize);
        }
Example #9
0
        /// <summary>
        /// Deletes index folder with the specific indexId, but has the option to first archive the index if it exists.
        /// The zip archive will be placed next to the root directory for that index with a timestamp included in its name.
        /// </summary>
        /// <param name="fs"> <seealso cref="FileSystemAbstraction"/> this index lives in. </param>
        /// <param name="directoryStructure"> <seealso cref="IndexDirectoryStructure"/> knowing the directory structure for the provider owning the index. </param>
        /// <param name="indexId"> id of the index. </param>
        /// <param name="archiveIfExists"> whether or not to archive the index before deleting it, if it exists. </param>
        /// <returns> whether or not an archive was created. </returns>
        /// <exception cref="IOException"> on I/O error. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static boolean deleteIndex(org.neo4j.io.fs.FileSystemAbstraction fs, org.neo4j.kernel.api.index.IndexDirectoryStructure directoryStructure, long indexId, boolean archiveIfExists) throws java.io.IOException
        public static bool DeleteIndex(FileSystemAbstraction fs, IndexDirectoryStructure directoryStructure, long indexId, bool archiveIfExists)
        {
            File rootIndexDirectory = directoryStructure.DirectoryForIndex(indexId);

            if (archiveIfExists && fs.IsDirectory(rootIndexDirectory) && fs.FileExists(rootIndexDirectory) && fs.ListFiles(rootIndexDirectory).Length > 0)
            {
                ZipUtils.zip(fs, rootIndexDirectory, new File(rootIndexDirectory.Parent, "archive-" + rootIndexDirectory.Name + "-" + DateTimeHelper.CurrentUnixTimeMillis() + ".zip"));
                return(true);
            }
            int attempt = 0;

            while (attempt < 5)
            {
                attempt++;
                try
                {
                    fs.DeleteRecursively(rootIndexDirectory);
                    break;
                }
                catch (Exception concurrentModificationException) when(concurrentModificationException is DirectoryNotEmptyException || concurrentModificationException is NoSuchFileException)
                {
                    // Looks like someone was poking around in our directory while we where deleting.
                    // Let's sleep for a bit and try again.
                    try
                    {
                        Thread.Sleep(100);
                    }
                    catch (InterruptedException)
                    {
                        // Let's abandon this attempt to clean up.
                        Thread.CurrentThread.Interrupt();
                        break;
                    }
                }
            }
            return(false);
        }
Example #10
0
 internal SpatialIndexFiles(IndexDirectoryStructure directoryStructure, long indexId, FileSystemAbstraction fs, ConfiguredSpaceFillingCurveSettingsCache settingsCache)
 {
     this._fs = fs;
     this._configuredSettings = settingsCache;
     _indexDirectory          = directoryStructure.DirectoryForIndex(indexId);
 }
Example #11
0
 public BlockBasedIndexPopulatorAnonymousInnerClass(BlockBasedIndexPopulatorTest outerInstance, Org.Neo4j.Io.pagecache.PageCache pageCache, FileSystemAbstraction fs, File indexFile, Org.Neo4j.Kernel.Impl.Index.Schema.GenericLayout layout, UnknownType empty, StoreIndexDescriptor indexDescriptor, IndexSpecificSpaceFillingCurveSettingsCache spatialSettings, IndexDirectoryStructure directoryStructure, Org.Neo4j.Kernel.Impl.Index.Schema.IndexDropAction dropAction, Org.Neo4j.Kernel.Impl.Index.Schema.ByteBufferFactory bufferFactory, Org.Neo4j.Kernel.Impl.Index.Schema.BlockStorage.Monitor monitor) : base(pageCache, fs, indexFile, layout, empty, indexDescriptor, spatialSettings, directoryStructure, dropAction, false, bufferFactory, 2, monitor)
 {
     this.outerInstance = outerInstance;
 }
Example #12
0
        public static IndexDirectoryStructure.Factory SubProviderDirectoryStructure(File databaseDirectory, IndexProviderDescriptor descriptor)
        {
            IndexDirectoryStructure parentDirectoryStructure = directoriesByProvider(databaseDirectory).forProvider(descriptor);

            return(directoriesBySubProvider(parentDirectoryStructure));
        }
Example #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void deleteIndexFolder(java.io.File databaseDir, org.neo4j.io.fs.FileSystemAbstraction fs) throws java.io.IOException
        private void DeleteIndexFolder(File databaseDir, FileSystemAbstraction fs)
        {
            fs.DeleteRecursively(IndexDirectoryStructure.baseSchemaIndexFolder(databaseDir));
        }
Example #14
0
 internal BlockBasedIndexPopulator(PageCache pageCache, FileSystemAbstraction fs, File file, IndexLayout <KEY, VALUE> layout, IndexProvider.Monitor monitor, StoreIndexDescriptor descriptor, IndexSpecificSpaceFillingCurveSettingsCache spatialSettings, IndexDirectoryStructure directoryStructure, IndexDropAction dropAction, bool archiveFailedIndex, ByteBufferFactory bufferFactory) : this(pageCache, fs, file, layout, monitor, descriptor, spatialSettings, directoryStructure, dropAction, archiveFailedIndex, bufferFactory, FeatureToggles.getInteger(typeof(BlockBasedIndexPopulator), "mergeFactor", 8), NO_MONITOR)
 {
 }
Example #15
0
 internal static IndexDirectoryStructure NativeIndexDirectoryStructure(DatabaseLayout databaseLayout)
 {
     return(IndexDirectoryStructure.directoriesByProvider(databaseLayout.DatabaseDirectory()).forProvider(GenericNativeIndexProvider.DESCRIPTOR));
 }
Example #16
0
 internal GenericBlockBasedIndexPopulator(PageCache pageCache, FileSystemAbstraction fs, File file, IndexLayout <GenericKey, NativeIndexValue> layout, IndexProvider.Monitor monitor, StoreIndexDescriptor descriptor, IndexSpecificSpaceFillingCurveSettingsCache spatialSettings, IndexDirectoryStructure directoryStructure, SpaceFillingCurveConfiguration configuration, IndexDropAction dropAction, bool archiveFailedIndex, ByteBufferFactory bufferFactory) : base(pageCache, fs, file, layout, monitor, descriptor, spatialSettings, directoryStructure, dropAction, archiveFailedIndex, bufferFactory)
 {
     this._spatialSettings = spatialSettings;
     this._configuration   = configuration;
 }
Example #17
0
 internal FaultyIndexStorageFactory(LuceneSchemaIndexCorruptionTest outerInstance, long faultyIndexId, Exception error, DirectoryFactory directoryFactory, IndexDirectoryStructure directoryStructure) : base(directoryFactory, outerInstance.fs, directoryStructure)
 {
     this._outerInstance = outerInstance;
     this.FaultyIndexId  = faultyIndexId;
     this.Error          = error;
 }